codeant-ai-for-open-source[bot] commented on code in PR #35754:
URL: https://github.com/apache/superset/pull/35754#discussion_r3680643418
##########
superset-embedded-sdk/src/index.ts:
##########
@@ -355,6 +356,18 @@ export async function embedDashboard({
ourPort.get<string>("getDashboardPermalink", { anchor });
const getActiveTabs = () => ourPort.get<string[]>("getActiveTabs");
const getDataMask = () => ourPort.get<Record<string, any>>("getDataMask");
+ // `observeDataMask` hands the host a mask with the change-trigger booleans
+ // mixed in, so feeding that payload straight back into `setDataMask` is a
+ // natural thing for a host to do. Keep only the entries that look like a
+ // filter's mask, so those flags never reach the dashboard as filter ids.
+ const setDataMask = (dataMask: Record<string, any>) =>
+ ourPort.emit("setDataMask", {
+ dataMask: Object.fromEntries(
+ Object.entries(dataMask).filter(
+ ([, mask]) => typeof mask === "object" && mask !== null,
+ ),
+ ),
+ });
Review Comment:
**Suggestion:** The SDK sends this new method using `emit`, and
Switchboard's emit path does not return an acknowledgement or error when the
iframe does not define the method. If the SDK and embedded page are deployed at
different versions, `setDataMask` appears to succeed but silently does nothing.
Add a capability/acknowledgement mechanism or expose a failure when the peer
does not support the method. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Filter updates silently fail across SDK/page version skew.
- ⚠️ Host applications cannot detect unsupported embedded API versions.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=48c9d27901d94c4c910b06376d4a3eff&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=48c9d27901d94c4c910b06376d4a3eff&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-embedded-sdk/src/index.ts
**Line:** 363:370
**Comment:**
*Api Mismatch: The SDK sends this new method using `emit`, and
Switchboard's emit path does not return an acknowledgement or error when the
iframe does not define the method. If the SDK and embedded page are deployed at
different versions, `setDataMask` appears to succeed but silently does nothing.
Add a capability/acknowledgement mechanism or expose a failure when the peer
does not support the method.
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%2F35754&comment_hash=ce9907801d3b6c9787fa052e9f4d69a6829fd0e2f38a294097a1ac499653e030&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F35754&comment_hash=ce9907801d3b6c9787fa052e9f4d69a6829fd0e2f38a294097a1ac499653e030&reaction=dislike'>👎</a>
##########
superset-frontend/src/embedded/api.tsx:
##########
@@ -83,6 +88,32 @@ const getActiveTabs = () =>
store?.getState()?.dashboardState?.activeTabs || [];
const getDataMask = () => store?.getState()?.dataMask || {};
+const setDataMask = ({ dataMask }: { dataMask: DataMaskStateWithId }) => {
+ // The dashboard's own data mask holds an entry for every native filter and
+ // every cross-filter-capable chart, so it doubles as the set of filter ids
+ // this dashboard can accept. Anything else — a filter id from a different
+ // dashboard, or the change-trigger flags that `observeDataMask` emits
+ // alongside the mask — would otherwise be inserted as a bogus filter and
+ // treated as a globally scoped filter by the active-filter derivation.
+ const knownFilterIds = new Set(Object.keys(getDataMask()));
+ const [applicable, ignored] = partition(Object.entries(dataMask), ([id]) =>
+ knownFilterIds.has(id),
+ );
Review Comment:
**Suggestion:** Because the allowlist is taken from the current Redux
`dataMask`, calls made immediately after `embedDashboard()` resolves can be
ignored before dashboard hydration has populated the filter entries. Hydration
then replaces the temporary state, so the requested values are permanently lost
and there is no retry. Queue the requested mask until hydration completes, or
avoid rejecting valid filter IDs solely because the store is not initialized
yet. [stale reference]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Immediate post-embed filter updates are permanently lost.
- ⚠️ Embedded dashboard filters may show default values unexpectedly.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=556080ae20b74f368edfb7bed89c86e6&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=556080ae20b74f368edfb7bed89c86e6&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/embedded/api.tsx
**Line:** 98:101
**Comment:**
*Stale Reference: Because the allowlist is taken from the current Redux
`dataMask`, calls made immediately after `embedDashboard()` resolves can be
ignored before dashboard hydration has populated the filter entries. Hydration
then replaces the temporary state, so the requested values are permanently lost
and there is no retry. Queue the requested mask until hydration completes, or
avoid rejecting valid filter IDs solely because the store is not initialized
yet.
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%2F35754&comment_hash=f3467155f433c35f303947166fb84668e67a7b272fa9e7ee4571b0380735ed36&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F35754&comment_hash=f3467155f433c35f303947166fb84668e67a7b272fa9e7ee4571b0380735ed36&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]