codeant-ai-for-open-source[bot] commented on code in PR #40833:
URL: https://github.com/apache/superset/pull/40833#discussion_r3486152127
##########
superset-frontend/src/utils/navigationUtils.ts:
##########
@@ -30,7 +34,17 @@ export const navigateTo = (
'noopener noreferrer',
);
} else if (options?.assign) {
- window.location.assign(sanitizeUrl(ensureAppRoot(url)));
+ const sanitized = sanitizeUrl(ensureAppRoot(url));
+ const now = Date.now();
+ if (
+ lastAssignUrl === sanitized &&
+ now - lastAssignAt < DUPLICATE_NAV_WINDOW_MS
+ ) {
+ return;
+ }
+ lastAssignUrl = sanitized;
+ lastAssignAt = now;
+ window.location.assign(sanitized);
Review Comment:
**Suggestion:** The dedupe state is recorded before attempting navigation,
so if `window.location.assign` throws (for example in restricted/sandboxed
browsing contexts), later retries to the same URL within the window are
incorrectly suppressed even though no navigation happened. Update the logic to
only keep the dedupe marker after a successful assign, or clear it in a catch
path when assign fails. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Dashboard create button misbehaves in sandboxed browsing contexts.
- ⚠️ Chart create button misbehaves in sandboxed browsing contexts.
- ⚠️ Users cannot immediately retry failed navigation attempts.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the Dashboards list page rendered by `DashboardList` in
`superset-frontend/src/pages/DashboardList/index.tsx:739`, where the **+
Dashboard**
button’s `onClick` calls `navigateTo('/dashboard/new', { assign: true })`.
2. Run Superset’s frontend in a restricted or sandboxed browsing context
(for example, the
Dashboards list loaded inside a sandboxed iframe without
`allow-top-navigation`), so that
`window.location.assign` can throw a `SecurityError` when trying to navigate.
3. Click the **+ Dashboard** button once: `navigateTo` in
`superset-frontend/src/utils/navigationUtils.ts:26-47` computes `sanitized`
at line 37,
sets `lastAssignUrl = sanitized` and `lastAssignAt = now` at lines 45-46,
then calls
`window.location.assign(sanitized)` at line 47, which throws before
navigation completes.
4. Immediately click the **+ Dashboard** button again within 1000ms:
`navigateTo` re-runs,
hits the dedupe check at lines 39-43 where `lastAssignUrl === sanitized` and
`now -
lastAssignAt < DUPLICATE_NAV_WINDOW_MS`, returns early at line 43, and
`window.location.assign` is never retried, so legitimate immediate retries
are suppressed
even though the first navigation failed.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3a46270aaac74416a1cd5e3bf42f74b5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3a46270aaac74416a1cd5e3bf42f74b5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/utils/navigationUtils.ts
**Line:** 45:47
**Comment:**
*Logic Error: The dedupe state is recorded before attempting
navigation, so if `window.location.assign` throws (for example in
restricted/sandboxed browsing contexts), later retries to the same URL within
the window are incorrectly suppressed even though no navigation happened.
Update the logic to only keep the dedupe marker after a successful assign, or
clear it in a catch path when assign fails.
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.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40833&comment_hash=79750b07a16ace8e5a797386335ef978eb176f8297ad5bc88cb735a1a44758b1&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40833&comment_hash=79750b07a16ace8e5a797386335ef978eb176f8297ad5bc88cb735a1a44758b1&reaction=dislike'>👎</a>
--
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]