codeant-ai-for-open-source[bot] commented on code in PR #36490:
URL: https://github.com/apache/superset/pull/36490#discussion_r2605998667
##########
superset-frontend/src/features/home/RightMenu.tsx:
##########
@@ -343,6 +343,7 @@ const RightMenu = ({
const handleLogout = () => {
localStorage.removeItem('redux');
+ sessionStorage.removeItem('login_attempted');
Review Comment:
**Suggestion:** Accessing `sessionStorage` can throw in non-browser
environments or when storage is disabled; wrap storage access in a safe
check/try-catch to avoid runtime exceptions during server-side rendering or in
restrictive browser settings. [possible bug]
**Severity Level:** Critical 🚨
```suggestion
try {
// localStorage/sessionStorage access can throw in SSR or when disabled
if (typeof localStorage !== 'undefined' && localStorage?.removeItem) {
localStorage.removeItem('redux');
}
if (typeof sessionStorage !== 'undefined' &&
sessionStorage?.removeItem) {
sessionStorage.removeItem('login_attempted');
}
} catch (err) {
// swallow storage errors to avoid crashing the UI
}
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
Accessing storage can throw in environments with disabled storage or unusual
browser privacy modes; wrapping access in a try/catch or guarding with typeof
checks prevents a hard crash when logout is triggered. The improved code is
defensive and addresses a real runtime failure mode without changing behavior
otherwise.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/features/home/RightMenu.tsx
**Line:** 345:346
**Comment:**
*Possible Bug: Accessing `sessionStorage` can throw in non-browser
environments or when storage is disabled; wrap storage access in a safe
check/try-catch to avoid runtime exceptions during server-side rendering or in
restrictive browser settings.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]