codeant-ai-for-open-source[bot] commented on code in PR #41636:
URL: https://github.com/apache/superset/pull/41636#discussion_r3509877578


##########
superset-frontend/packages/superset-core/src/theme/utils/index.ts:
##########
@@ -74,9 +74,17 @@ export function deserializeThemeConfig(
     resolvedAlgorithm = antdThemeImport.defaultAlgorithm;
   }
 
+  // Ant Design v6 dropped `boolean` from ThemeConfig['cssVar'] (it is now
+  // object-only, and CSS variables are enabled by default). Superset keeps a
+  // boolean-friendly serializable API, so coerce at the antd boundary:
+  // `true` -> `{}` (defaults), `false`/undefined -> omit (antd default).
+  const normalizedCssVar =
+    typeof cssVar === 'boolean' ? (cssVar ? {} : undefined) : cssVar;

Review Comment:
   **Suggestion:** The `cssVar` normalization collapses `false` into 
`undefined`, so an explicitly disabled value is lost and cannot be 
round-tripped through the serializer/deserializer pipeline. This breaks the 
public config contract by making `cssVar: false` indistinguishable from “not 
provided”; preserve an explicit disabled state instead of dropping it. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Dashboard theme exports drop explicit cssVar disabled flag.
   - ⚠️ ThemeController responses cannot distinguish unset vs disabled cssVar.
   - ⚠️ External clients lose fidelity persisting dashboard theme JSON.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Save or construct a serializable theme config object typed as 
`SerializableThemeConfig`
   with `cssVar: false`, e.g. in dashboard theme JSON handled by
   `ThemeController.normalizeTheme()` at
   `superset-frontend/src/theme/ThemeController.ts:17-19`, where the argument 
type is
   `AnyThemeConfig` and `SerializableThemeConfig` (with `cssVar?: boolean | { 
key?: string;
   prefix?: string }`) is defined in
   `superset-frontend/packages/superset-core/src/theme/types.ts:75-82`.
   
   2. When this config is passed through the shared normalizer,
   `ThemeController.normalizeTheme()` calls `normalizeThemeConfig(theme)` at
   `superset-frontend/src/theme/ThemeController.ts:17-19`, which in turn calls
   `isSerializableConfig(config)` and then `deserializeThemeConfig(config)` at
   `superset-frontend/packages/superset-core/src/theme/utils/index.ts:32-43` 
and `130-133`;
   since `algorithm` is `undefined`, `isSerializableConfig` treats the config 
as serializable
   and forwards it to `deserializeThemeConfig`.
   
   3. Inside `deserializeThemeConfig` at
   `superset-frontend/packages/superset-core/src/theme/utils/index.ts:48-88`, 
the function
   destructures `{ algorithm, cssVar, ...rest }` and computes 
`normalizedCssVar` at lines
   81-82, mapping a boolean `cssVar` to `{}` when `true` and to `undefined` 
when `false`,
   then builds the Ant Design theme config spread only with 
`...(normalizedCssVar !==
   undefined ? { cssVar: normalizedCssVar } : {})`; for `cssVar: false`, this 
omits the
   `cssVar` property entirely from the resulting `AntdThemeConfig`.
   
   4. Later, when the theme is re-serialized for external consumption—e.g. via
   `Theme.fromConfig(normalizedTheme, baseTheme).toSerializedConfig()` in
   `ThemeController.getThemeForContext()` at
   `superset-frontend/src/theme/ThemeController.ts:19-22`, or via 
`Theme.json()` at
   `superset-frontend/packages/superset-core/src/theme/Theme.tsx:73-75`—the 
serializer
   `serializeThemeConfig(this.antdConfig)` at
   `superset-frontend/packages/superset-core/src/theme/utils/index.ts:94-123` 
spreads
   `...rest` from the `AntdThemeConfig`, which no longer contains `cssVar`, so 
the exported
   `SerializableThemeConfig` has `cssVar` unset and the original explicit 
`cssVar: false`
   value cannot be round-tripped or distinguished from “not provided”.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=026ea8ecb3184c70a51184d8f03f1f76&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=026ea8ecb3184c70a51184d8f03f1f76&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/packages/superset-core/src/theme/utils/index.ts
   **Line:** 81:82
   **Comment:**
        *Api Mismatch: The `cssVar` normalization collapses `false` into 
`undefined`, so an explicitly disabled value is lost and cannot be 
round-tripped through the serializer/deserializer pipeline. This breaks the 
public config contract by making `cssVar: false` indistinguishable from “not 
provided”; preserve an explicit disabled state instead of dropping it.
   
   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%2F41636&comment_hash=ae421fde1e39e51c6ebb0f4aac7e93ddd101ab448b31ad5c7383fb2c8f104ef7&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41636&comment_hash=ae421fde1e39e51c6ebb0f4aac7e93ddd101ab448b31ad5c7383fb2c8f104ef7&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]

Reply via email to