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


##########
superset/views/base.py:
##########
@@ -576,7 +577,24 @@ def common_bootstrap_payload() -> dict[str, Any]:
     locale = get_locale()
     # Convert locale to string for proper cache key hashing
     locale_str = str(locale) if locale else None
-    return cached_common_bootstrap_data(utils.get_user_id(), locale_str)
+    payload = dict(cached_common_bootstrap_data(utils.get_user_id(), 
locale_str))

Review Comment:
   **Suggestion:** Add an explicit type annotation to this newly introduced 
local payload object so the modified code complies with the type-hinting rule. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly introduced local variable in modified Python code and it is 
not type annotated, which matches the type-hint requirement for relevant 
variables that can be annotated.
   </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=6f36185f2d2149a894cf3e20b2101dcb&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=6f36185f2d2149a894cf3e20b2101dcb&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/views/base.py
   **Line:** 580:580
   **Comment:**
        *Custom Rule: Add an explicit type annotation to this newly introduced 
local payload object so the modified code complies with the type-hinting rule.
   
   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%2F39357&comment_hash=64a251d05eb9f33aa29e2fb26dae68ea013d23cffd510c8e488505a02ad1f859&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=64a251d05eb9f33aa29e2fb26dae68ea013d23cffd510c8e488505a02ad1f859&reaction=dislike'>👎</a>



##########
superset/views/base.py:
##########
@@ -576,7 +577,24 @@ def common_bootstrap_payload() -> dict[str, Any]:
     locale = get_locale()
     # Convert locale to string for proper cache key hashing
     locale_str = str(locale) if locale else None
-    return cached_common_bootstrap_data(utils.get_user_id(), locale_str)
+    payload = dict(cached_common_bootstrap_data(utils.get_user_id(), 
locale_str))
+    # Inject the Jed language pack outside the per-user memoize so the cached
+    # payload stays small and the pack is shared across users for the same
+    # locale. The frontend uses it to configure the translator synchronously,
+    # before any code-split chunk evaluates a module-level `const X = t('...')`
+    # (upstream issue #35330).
+    language = payload.get("locale")

Review Comment:
   **Suggestion:** Add a concrete type hint for this new local locale-derived 
value to keep modified logic fully typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This local variable is newly introduced in the modified function body and 
lacks an explicit type hint, so it violates the type-hint rule for annotatable 
variables.
   </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=6ace9c1eb64746b698de467f6f4c7aca&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=6ace9c1eb64746b698de467f6f4c7aca&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/views/base.py
   **Line:** 586:586
   **Comment:**
        *Custom Rule: Add a concrete type hint for this new local 
locale-derived value to keep modified logic fully typed.
   
   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%2F39357&comment_hash=4bc071a8818c30798795b989dfbba1c2fef139810fe6a1216c66fe947b130989&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=4bc071a8818c30798795b989dfbba1c2fef139810fe6a1216c66fe947b130989&reaction=dislike'>👎</a>



##########
superset/views/base.py:
##########
@@ -576,7 +577,24 @@ def common_bootstrap_payload() -> dict[str, Any]:
     locale = get_locale()
     # Convert locale to string for proper cache key hashing
     locale_str = str(locale) if locale else None
-    return cached_common_bootstrap_data(utils.get_user_id(), locale_str)
+    payload = dict(cached_common_bootstrap_data(utils.get_user_id(), 
locale_str))
+    # Inject the Jed language pack outside the per-user memoize so the cached
+    # payload stays small and the pack is shared across users for the same
+    # locale. The frontend uses it to configure the translator synchronously,
+    # before any code-split chunk evaluates a module-level `const X = t('...')`
+    # (upstream issue #35330).
+    language = payload.get("locale")
+    if language and language != "en":
+        # Respect a pack already provided via COMMON_BOOTSTRAP_OVERRIDES_FUNC
+        # (the workaround in #35330 does exactly that), otherwise load the
+        # shared one. `get_language_pack` returns the empty English pack on a
+        # miss, which is the right result (English) when no translation file
+        # exists.
+        pack = payload.get("language_pack") or get_language_pack(language)

Review Comment:
   **Suggestion:** Type-annotate this new local variable that is assigned 
conditionally so the added branch logic remains compliant with required 
annotations. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added local variable assigned in the new branch logic and it 
is not annotated, which fits the type-hint rule for relevant variables.
   </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=d0d51f2929ed4252a196fd66c52bb0ce&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=d0d51f2929ed4252a196fd66c52bb0ce&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/views/base.py
   **Line:** 593:593
   **Comment:**
        *Custom Rule: Type-annotate this new local variable that is assigned 
conditionally so the added branch logic remains compliant with required 
annotations.
   
   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%2F39357&comment_hash=ed1a10695d7ba49ce324666a58fb5269262b1131be966279f690a238a7bd0ce3&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=ed1a10695d7ba49ce324666a58fb5269262b1131be966279f690a238a7bd0ce3&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-core/src/translation/TranslatorSingleton.test.ts:
##########
@@ -173,3 +173,82 @@ test('resetTranslation does nothing when not yet 
configured', () => {
     consoleSpy.mockRestore();
   });
 });
+
+// --- autoConfigureFromWindow ----------------------------------------------
+// These cover the bootstrap-injection path used to dodge the
+// module-level `const X = t(...)` race across code-split chunks
+// (upstream issue #35330).
+
+test('t() self-configures from window.__SUPERSET_LANGUAGE_PACK__ on first 
call', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {

Review Comment:
   **Suggestion:** Replace the `any` cast by using a typed global window 
extension for `__SUPERSET_LANGUAGE_PACK__`. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The code uses a TypeScript `any` cast on `window` when assigning the global 
`__SUPERSET_LANGUAGE_PACK__` property, which directly violates the no-any-types 
rule.
   </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=806560c9ddb54597bd09d0c8a1b32b15&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=806560c9ddb54597bd09d0c8a1b32b15&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/translation/TranslatorSingleton.test.ts
   **Line:** 184:184
   **Comment:**
        *Custom Rule: Replace the `any` cast by using a typed global window 
extension for `__SUPERSET_LANGUAGE_PACK__`.
   
   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%2F39357&comment_hash=1628e5117135aa69e0723e1eb5eab11ac7834e8720bbfc2cb8d7e1d4bda85d82&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=1628e5117135aa69e0723e1eb5eab11ac7834e8720bbfc2cb8d7e1d4bda85d82&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-core/src/translation/TranslatorSingleton.test.ts:
##########
@@ -173,3 +173,82 @@ test('resetTranslation does nothing when not yet 
configured', () => {
     consoleSpy.mockRestore();
   });
 });
+
+// --- autoConfigureFromWindow ----------------------------------------------
+// These cover the bootstrap-injection path used to dodge the
+// module-level `const X = t(...)` race across code-split chunks
+// (upstream issue #35330).
+
+test('t() self-configures from window.__SUPERSET_LANGUAGE_PACK__ on first 
call', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {
+      domain: 'superset',
+      locale_data: {
+        superset: {
+          '': {
+            domain: 'superset',
+            lang: 'fr',
+            plural_forms: 'nplurals=2; plural=(n > 1);',
+          },
+          hello: ['bonjour'],
+        },
+      },
+    };
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('bonjour');
+    // No "should call configure" warning because we self-configured first.
+    expect(consoleSpy).not.toHaveBeenCalled();
+    consoleSpy.mockRestore();
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;
+  });
+});
+
+test('t() falls back to msgid when window has no language pack', () => {
+  jest.isolateModules(() => {
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('hello');
+    expect(consoleSpy).toHaveBeenCalledWith(
+      expect.stringMatching(/was called before configure\(\)/),
+    );
+    consoleSpy.mockRestore();
+  });
+});
+
+test('explicit configure() takes precedence over window pack', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {

Review Comment:
   **Suggestion:** Assign `__SUPERSET_LANGUAGE_PACK__` through a properly typed 
window interface rather than `any`. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The assignment again uses `(window as any)`, which is exactly the kind of 
TypeScript `any` usage prohibited by the rule.
   </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=88a2d834608d4aa1a5eb277b0edcf814&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=88a2d834608d4aa1a5eb277b0edcf814&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/translation/TranslatorSingleton.test.ts
   **Line:** 222:222
   **Comment:**
        *Custom Rule: Assign `__SUPERSET_LANGUAGE_PACK__` through a properly 
typed window interface rather than `any`.
   
   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%2F39357&comment_hash=a3f6ddb86411553c032194e84bebeec6137234d9bc3362a5792558b1ed659cce&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=a3f6ddb86411553c032194e84bebeec6137234d9bc3362a5792558b1ed659cce&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-core/src/translation/TranslatorSingleton.test.ts:
##########
@@ -173,3 +173,82 @@ test('resetTranslation does nothing when not yet 
configured', () => {
     consoleSpy.mockRestore();
   });
 });
+
+// --- autoConfigureFromWindow ----------------------------------------------
+// These cover the bootstrap-injection path used to dodge the
+// module-level `const X = t(...)` race across code-split chunks
+// (upstream issue #35330).
+
+test('t() self-configures from window.__SUPERSET_LANGUAGE_PACK__ on first 
call', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {
+      domain: 'superset',
+      locale_data: {
+        superset: {
+          '': {
+            domain: 'superset',
+            lang: 'fr',
+            plural_forms: 'nplurals=2; plural=(n > 1);',
+          },
+          hello: ['bonjour'],
+        },
+      },
+    };
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('bonjour');
+    // No "should call configure" warning because we self-configured first.
+    expect(consoleSpy).not.toHaveBeenCalled();
+    consoleSpy.mockRestore();
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;

Review Comment:
   **Suggestion:** Use the same typed window extension when clearing 
`__SUPERSET_LANGUAGE_PACK__` instead of casting to `any`. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The deletion uses an `any` cast on `window`, so the file still contains a 
new TypeScript `any` usage that violates the rule.
   </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=c20054e5f5e14e49bea6187f2c71d74f&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=c20054e5f5e14e49bea6187f2c71d74f&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/translation/TranslatorSingleton.test.ts
   **Line:** 203:203
   **Comment:**
        *Custom Rule: Use the same typed window extension when clearing 
`__SUPERSET_LANGUAGE_PACK__` instead of casting to `any`.
   
   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%2F39357&comment_hash=b60e46e9fd27df24e8ac37a5c04598849f5a0107671f42aa61a4b11ef71dbc09&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=b60e46e9fd27df24e8ac37a5c04598849f5a0107671f42aa61a4b11ef71dbc09&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-core/src/translation/TranslatorSingleton.test.ts:
##########
@@ -173,3 +173,82 @@ test('resetTranslation does nothing when not yet 
configured', () => {
     consoleSpy.mockRestore();
   });
 });
+
+// --- autoConfigureFromWindow ----------------------------------------------
+// These cover the bootstrap-injection path used to dodge the
+// module-level `const X = t(...)` race across code-split chunks
+// (upstream issue #35330).
+
+test('t() self-configures from window.__SUPERSET_LANGUAGE_PACK__ on first 
call', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {
+      domain: 'superset',
+      locale_data: {
+        superset: {
+          '': {
+            domain: 'superset',
+            lang: 'fr',
+            plural_forms: 'nplurals=2; plural=(n > 1);',
+          },
+          hello: ['bonjour'],
+        },
+      },
+    };
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('bonjour');
+    // No "should call configure" warning because we self-configured first.
+    expect(consoleSpy).not.toHaveBeenCalled();
+    consoleSpy.mockRestore();
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;
+  });
+});
+
+test('t() falls back to msgid when window has no language pack', () => {
+  jest.isolateModules(() => {
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;

Review Comment:
   **Suggestion:** Replace the `any` cast with a concrete window type when 
deleting `__SUPERSET_LANGUAGE_PACK__`. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is another occurrence of the same `any` cast on `window`, so the custom 
no-any rule is genuinely violated here as well.
   </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=925b130ed7374f03ac587e41d6c150b7&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=925b130ed7374f03ac587e41d6c150b7&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/translation/TranslatorSingleton.test.ts
   **Line:** 209:209
   **Comment:**
        *Custom Rule: Replace the `any` cast with a concrete window type when 
deleting `__SUPERSET_LANGUAGE_PACK__`.
   
   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%2F39357&comment_hash=238d14a399880f214731e465cc218fee1eb354e92f37a8f9cc46db0b08bfbc78&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=238d14a399880f214731e465cc218fee1eb354e92f37a8f9cc46db0b08bfbc78&reaction=dislike'>👎</a>



##########
superset-frontend/packages/superset-core/src/translation/TranslatorSingleton.test.ts:
##########
@@ -173,3 +173,82 @@ test('resetTranslation does nothing when not yet 
configured', () => {
     consoleSpy.mockRestore();
   });
 });
+
+// --- autoConfigureFromWindow ----------------------------------------------
+// These cover the bootstrap-injection path used to dodge the
+// module-level `const X = t(...)` race across code-split chunks
+// (upstream issue #35330).
+
+test('t() self-configures from window.__SUPERSET_LANGUAGE_PACK__ on first 
call', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {
+      domain: 'superset',
+      locale_data: {
+        superset: {
+          '': {
+            domain: 'superset',
+            lang: 'fr',
+            plural_forms: 'nplurals=2; plural=(n > 1);',
+          },
+          hello: ['bonjour'],
+        },
+      },
+    };
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('bonjour');
+    // No "should call configure" warning because we self-configured first.
+    expect(consoleSpy).not.toHaveBeenCalled();
+    consoleSpy.mockRestore();
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;
+  });
+});
+
+test('t() falls back to msgid when window has no language pack', () => {
+  jest.isolateModules(() => {
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;
+    const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => 
{});
+    const { t } = require('./TranslatorSingleton');
+    expect(t('hello')).toBe('hello');
+    expect(consoleSpy).toHaveBeenCalledWith(
+      expect.stringMatching(/was called before configure\(\)/),
+    );
+    consoleSpy.mockRestore();
+  });
+});
+
+test('explicit configure() takes precedence over window pack', () => {
+  jest.isolateModules(() => {
+    (window as any).__SUPERSET_LANGUAGE_PACK__ = {
+      domain: 'superset',
+      locale_data: {
+        superset: {
+          '': {
+            domain: 'superset',
+            lang: 'fr',
+            plural_forms: 'nplurals=2; plural=(n > 1);',
+          },
+          hello: ['bonjour'],
+        },
+      },
+    };
+    const { configure, t } = require('./TranslatorSingleton');
+    configure({
+      languagePack: {
+        domain: 'superset',
+        locale_data: {
+          superset: {
+            '': {
+              domain: 'superset',
+              lang: 'es',
+              plural_forms: 'nplurals=2; plural=(n != 1);',
+            },
+            hello: ['hola'],
+          },
+        },
+      },
+    });
+    expect(t('hello')).toBe('hola');
+    delete (window as any).__SUPERSET_LANGUAGE_PACK__;

Review Comment:
   **Suggestion:** Use a concrete type for `window` when deleting 
`__SUPERSET_LANGUAGE_PACK__` instead of `any`. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This line also contains the `any` cast on `window`, so it is a real instance 
of the no-any-types violation.
   </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=bac02f86ca2a411cab806b258b821421&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=bac02f86ca2a411cab806b258b821421&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/translation/TranslatorSingleton.test.ts
   **Line:** 252:252
   **Comment:**
        *Custom Rule: Use a concrete type for `window` when deleting 
`__SUPERSET_LANGUAGE_PACK__` instead of `any`.
   
   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%2F39357&comment_hash=d3998dc911ec9a2f89f88eb45e2c8b4ecbdce222fd5fae4ea37d78b93244f9c7&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=d3998dc911ec9a2f89f88eb45e2c8b4ecbdce222fd5fae4ea37d78b93244f9c7&reaction=dislike'>👎</a>



##########
tests/unit_tests/views/test_bootstrap_auth.py:
##########
@@ -133,3 +133,73 @@ def test_recaptcha_shown_for_non_federated_auth(
     payload = _get_bootstrap()
 
     assert payload["conf"]["RECAPTCHA_PUBLIC_KEY"] == "test-key"
+
+
+# --- language_pack injection --------------------------------------------
+#
+# The Jed pack is injected by `common_bootstrap_payload` (outside the
+# memoized `cached_common_bootstrap_data`) using the shared
+# `superset.translations.utils.get_language_pack`. Tests here cover the
+# wrapper to confirm the pack lands on the payload for non-English
+# locales and is None for English.
+
+
+def test_common_bootstrap_payload_includes_language_pack_for_non_english(
+    app_context: None,
+) -> None:
+    """common.language_pack carries the shared utility's pack for non-en."""
+    fake_pack = {"domain": "superset", "locale_data": {"superset": {}}}

Review Comment:
   **Suggestion:** Add an explicit type annotation for the newly introduced 
local dictionary variable to satisfy the type-hint requirement for relevant 
annotatable variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added local variable with an obvious dictionary type that 
can be annotated, and the rule requires type hints for relevant annotatable 
variables in new or modified Python code. The code currently omits that 
annotation, so the suggestion is a real rule violation.
   </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=8c069238101b445e902513594c25035f&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=8c069238101b445e902513594c25035f&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:** tests/unit_tests/views/test_bootstrap_auth.py
   **Line:** 151:151
   **Comment:**
        *Custom Rule: Add an explicit type annotation for the newly introduced 
local dictionary variable to satisfy the type-hint requirement for relevant 
annotatable variables.
   
   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%2F39357&comment_hash=a4527955a6da0a4794f2c59f59b3980da0a855accc625ea8d3d2db2dcc75e534&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39357&comment_hash=a4527955a6da0a4794f2c59f59b3980da0a855accc625ea8d3d2db2dcc75e534&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