bito-code-review[bot] commented on code in PR #40097:
URL: https://github.com/apache/superset/pull/40097#discussion_r3250599991
##########
superset/templates/superset/oauth2.html:
##########
@@ -16,14 +16,22 @@
specific language governing permissions and limitations
under the License.
-#}
+{% import "superset/macros.html" as macros %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
- <script>
- window.opener.postMessage({ tabId: '{{ tab_id }}' });
+ <script nonce="{{ macros.get_nonce() }}">
+ const message = { tabId: '{{ tab_id }}' };
+ if (typeof BroadcastChannel !== 'undefined') {
+ const channel = new BroadcastChannel('oauth');
+ channel.postMessage(message);
+ channel.close();
+ }
+ localStorage.setItem('oauth2_auth_complete', JSON.stringify(message));
+ localStorage.removeItem('oauth2_auth_complete');
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Broken localStorage notification pattern</b></div>
<div id="fix">
The setItem followed immediately by removeItem creates a race condition
where the parent tab's `storage` event listener may never receive the
notification. Also, `storage` events only fire for cross-origin changes, not
same-tab modifications. These lines are dead code that don't accomplish their
intended purpose.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- a/superset/templates/superset/oauth2.html
+++ b/superset/templates/superset/oauth2.html
@@ -30,8 +30,6 @@
channel.postMessage(message);
channel.close();
}
- localStorage.setItem('oauth2_auth_complete',
JSON.stringify(message));
- localStorage.removeItem('oauth2_auth_complete');
window.close();
</script>
```
</div>
</details>
</div>
<small><i>Code Review Run #7f0242</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]