codeant-ai-for-open-source[bot] commented on code in PR #41117:
URL: https://github.com/apache/superset/pull/41117#discussion_r3421706504
##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -78,6 +79,7 @@ const ExtensionsStartup: React.FC<{ children?:
React.ReactNode }> = ({
// Namespaces are listed explicitly — do not spread the core package here,
// as that would leak un-contracted symbols onto window.superset.
window.superset = {
+ ...supersetCore,
Review Comment:
**Suggestion:** Spreading `supersetCore` into `window.superset` leaks
non-host namespaces (for example `common`, `translation`, `components`, etc.)
that are explicitly outside the supported host contract. This breaks the
extension API boundary and can cause extensions to treat unsupported namespaces
as available, then fail at runtime when those leaked namespaces do not behave
like host-backed implementations. Remove the spread and keep `window.superset`
limited to the explicitly listed host namespaces. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Extension host API surface exceeds typed Namespaces contract.
- ⚠️ Extensions may depend on unstable, non-host-backed globals.
- ⚠️ Future tightening of window.superset can break extensions.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Start the Superset frontend so that `App` renders, which unconditionally
mounts
`ExtensionsStartup` as seen in `superset-frontend/src/views/App.tsx:14-24`
where
`<ExtensionsStartup>` wraps the route `<Switch>`.
2. When `ExtensionsStartup` mounts, its effect at
`superset-frontend/src/extensions/ExtensionsStartup.tsx:77-93` runs and
assigns
`window.superset = { ...supersetCore, authentication, chat, core, commands,
editors,
extensions, menus, navigation, sqlLab, views }`, spreading every export from
`@apache-superset/core` onto `window.superset`.
3. The intended contract for `window.superset` is defined in
`superset-frontend/src/extensions/Namespaces.ts:42-53`, where the
`Namespaces` interface
only exposes `authentication`, `core`, `chat`, `commands`, `editors`,
`extensions`,
`menus`, `navigation`, `sqlLab`, and `views`, and `window.superset` is
declared as exactly
this type at lines 56-59.
4. In a running browser session, open DevTools and execute
`Object.keys(window.superset)`
after app load; you will see keys coming from `supersetCore` that are not
part of the
`Namespaces` interface (because `...supersetCore` was spread at
`ExtensionsStartup.tsx:82`), meaning extensions can observe and potentially
use these
non-contracted namespaces even though the comment at
`ExtensionsStartup.tsx:78-80`
explicitly says "do not spread the core package here, as that would leak
un-contracted
symbols onto window.superset," creating a concrete mismatch between the
public contract
(`Namespaces`) and the actual runtime API surface.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7ce8c1e5dca847d4991f36afa9c70c6d&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=7ce8c1e5dca847d4991f36afa9c70c6d&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/extensions/ExtensionsStartup.tsx
**Line:** 82:82
**Comment:**
*Api Mismatch: Spreading `supersetCore` into `window.superset` leaks
non-host namespaces (for example `common`, `translation`, `components`, etc.)
that are explicitly outside the supported host contract. This breaks the
extension API boundary and can cause extensions to treat unsupported namespaces
as available, then fail at runtime when those leaked namespaces do not behave
like host-backed implementations. Remove the spread and keep `window.superset`
limited to the explicitly listed host namespaces.
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%2F41117&comment_hash=16059cfefad71a22a255db668e017a76da10210584d8b0733d3cb820784cd9e9&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41117&comment_hash=16059cfefad71a22a255db668e017a76da10210584d8b0733d3cb820784cd9e9&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]