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


##########
superset-frontend/src/extensions/ExtensionsLoader.test.ts:
##########
@@ -48,9 +47,53 @@ function createMockExtension(overrides: Partial<Extension> = 
{}): Extension {
   };
 }
 
+// Simulate what real webpack does when __webpack_init_sharing__ runs: it
+// registers the host's own eagerly-provided @apache-superset/core versions
+// into the share scope.
+function mockWebpackSharing(coreVersions: Record<string, unknown> = {}) {
+  (globalThis as any).__webpack_init_sharing__ = jest
+    .fn()
+    .mockImplementation(() => {
+      (globalThis as any).__webpack_share_scopes__.default[
+        '@apache-superset/core'
+      ] = coreVersions;
+    });
+  (globalThis as any).__webpack_share_scopes__ = { default: {} };

Review Comment:
   **Suggestion:** Type the webpack share scopes object explicitly and remove 
the `any` cast from this assignment. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This is another direct `any` cast in TypeScript code, so the no-`any` rule 
is 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=5e4c1403642a47a2ab1afb0fd5a8443d&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=5e4c1403642a47a2ab1afb0fd5a8443d&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/ExtensionsLoader.test.ts
   **Line:** 61:61
   **Comment:**
        *Custom Rule: Type the webpack share scopes object explicitly and 
remove the `any` cast from this assignment.
   
   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%2F39171&comment_hash=ed4bf1ee0f8ec5dc25c65aba5b1daf36cc228859328fc2379638892b7d311198&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39171&comment_hash=ed4bf1ee0f8ec5dc25c65aba5b1daf36cc228859328fc2379638892b7d311198&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/extensions/ExtensionsLoader.test.ts:
##########
@@ -48,9 +47,53 @@ function createMockExtension(overrides: Partial<Extension> = 
{}): Extension {
   };
 }
 
+// Simulate what real webpack does when __webpack_init_sharing__ runs: it
+// registers the host's own eagerly-provided @apache-superset/core versions
+// into the share scope.
+function mockWebpackSharing(coreVersions: Record<string, unknown> = {}) {
+  (globalThis as any).__webpack_init_sharing__ = jest
+    .fn()
+    .mockImplementation(() => {
+      (globalThis as any).__webpack_share_scopes__.default[
+        '@apache-superset/core'
+      ] = coreVersions;
+    });
+  (globalThis as any).__webpack_share_scopes__ = { default: {} };
+}
+
+function cleanupWebpackSharing() {
+  delete (globalThis as any).__webpack_init_sharing__;
+  delete (globalThis as any).__webpack_share_scopes__;
+}
+
+// Intercept script element creation so onload fires synchronously in jsdom.
+function mockRemoteEntryLoad() {
+  return jest
+    .spyOn(document.head, 'appendChild')
+    .mockImplementation((el: Node) => {
+      if (el instanceof HTMLScriptElement && el.onload) {
+        (el as HTMLScriptElement).onload!(new Event('load'));
+      }
+      return el;
+    });
+}
+
 beforeEach(() => {
   (ExtensionsLoader as any).instance = undefined;
   mockApplicationRoot.mockReturnValue('');
+  // Reset window.superset to a base object before each test, including a
+  // shared singleton (commands) to verify identity is preserved across
+  // per-extension scoped copies.
+  (window as any).superset = {

Review Comment:
   **Suggestion:** Introduce a typed shape for `window.superset` in tests and 
assign through that type instead of casting `window` to `any`. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The code casts `window` to `any` to assign `superset`, which is a concrete 
instance of the banned `any` usage.
   </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=75ce581413a7423789d2acb975d6fc56&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=75ce581413a7423789d2acb975d6fc56&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/ExtensionsLoader.test.ts
   **Line:** 87:87
   **Comment:**
        *Custom Rule: Introduce a typed shape for `window.superset` in tests 
and assign through that type instead of casting `window` 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%2F39171&comment_hash=26b689b38f334625b3a5aef302bc7d066b456b1752906cd4fa19f16211582939&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39171&comment_hash=26b689b38f334625b3a5aef302bc7d066b456b1752906cd4fa19f16211582939&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/extensions/ExtensionsLoader.test.ts:
##########
@@ -170,6 +213,212 @@ test('logs success after initializeExtensions completes', 
async () => {
   infoSpy.mockRestore();
 });
 
+test('logs partial failure count when some extensions fail to initialize', 
async () => {
+  const loader = ExtensionsLoader.getInstance();
+  const infoSpy = jest.spyOn(logging, 'info').mockImplementation();
+  jest.spyOn(SupersetClient, 'get').mockResolvedValue({
+    json: {
+      result: [
+        createMockExtension({ id: 'good-ext', remoteEntry: '' }),
+        createMockExtension({
+          id: 'broken-ext',
+          remoteEntry: 'http://broken-url/remoteEntry.js',
+        }),
+      ],
+    },
+  } as any);
+  const appendChildSpy = jest
+    .spyOn(document.head, 'appendChild')
+    .mockImplementation((element: Node) => {
+      if (element instanceof HTMLScriptElement && element.onerror) {
+        setTimeout(() => {
+          (element.onerror as any)('Script load error');
+        }, 0);
+      }
+      return element;
+    });
+
+  await loader.initializeExtensions();
+
+  expect(infoSpy).toHaveBeenCalledWith(
+    expect.stringContaining('1 of 2 extension(s) failing'),
+  );
+  expect(loader.getExtension('good-ext')).toBeDefined();
+  expect(loader.getExtension('broken-ext')).toBeUndefined();
+
+  infoSpy.mockRestore();
+  appendChildSpy.mockRestore();
+});
+
+test('each extension gets an isolated getContext via module federation custom 
scope', async () => {
+  const loader = ExtensionsLoader.getInstance();
+
+  // Capture the scoped @apache-superset/core instance each container receives
+  const capturedCoreModules: Array<any> = [];

Review Comment:
   **Suggestion:** Replace the `Array<any>` declaration with a specific 
module/interface type that matches the captured core module shape. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   `Array<any>` is explicitly using `any` in a new TypeScript declaration, so 
it 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=179d02a8697a47949534a10869d84c44&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=179d02a8697a47949534a10869d84c44&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/ExtensionsLoader.test.ts
   **Line:** 257:257
   **Comment:**
        *Custom Rule: Replace the `Array<any>` declaration with a specific 
module/interface type that matches the captured core module shape.
   
   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%2F39171&comment_hash=9550f2e19c4abe29a972ceb1f20a77f6bc409168283c7051fb366785a036c819&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39171&comment_hash=9550f2e19c4abe29a972ceb1f20a77f6bc409168283c7051fb366785a036c819&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/extensions/ExtensionsLoader.test.ts:
##########
@@ -48,9 +47,53 @@ function createMockExtension(overrides: Partial<Extension> = 
{}): Extension {
   };
 }
 
+// Simulate what real webpack does when __webpack_init_sharing__ runs: it
+// registers the host's own eagerly-provided @apache-superset/core versions
+// into the share scope.
+function mockWebpackSharing(coreVersions: Record<string, unknown> = {}) {
+  (globalThis as any).__webpack_init_sharing__ = jest

Review Comment:
   **Suggestion:** Replace the untyped global cast with a dedicated typed 
interface for the webpack sharing globals instead of using `any`. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The file uses `any` in a TypeScript test via a cast on `globalThis`, which 
directly violates the no-`any` 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=232b9cca86164a15a6f002497a871ce9&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=232b9cca86164a15a6f002497a871ce9&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/ExtensionsLoader.test.ts
   **Line:** 54:54
   **Comment:**
        *Custom Rule: Replace the untyped global cast with a dedicated typed 
interface for the webpack sharing globals instead of using `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%2F39171&comment_hash=e1065c815dddda2652f35488939ec8efbd9f0d3d4e048330dfe01a22cd0b95ef&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39171&comment_hash=e1065c815dddda2652f35488939ec8efbd9f0d3d4e048330dfe01a22cd0b95ef&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/extensions/ExtensionsLoader.test.ts:
##########
@@ -170,6 +213,212 @@ test('logs success after initializeExtensions completes', 
async () => {
   infoSpy.mockRestore();
 });
 
+test('logs partial failure count when some extensions fail to initialize', 
async () => {
+  const loader = ExtensionsLoader.getInstance();
+  const infoSpy = jest.spyOn(logging, 'info').mockImplementation();
+  jest.spyOn(SupersetClient, 'get').mockResolvedValue({
+    json: {
+      result: [
+        createMockExtension({ id: 'good-ext', remoteEntry: '' }),
+        createMockExtension({
+          id: 'broken-ext',
+          remoteEntry: 'http://broken-url/remoteEntry.js',
+        }),
+      ],
+    },
+  } as any);
+  const appendChildSpy = jest
+    .spyOn(document.head, 'appendChild')
+    .mockImplementation((element: Node) => {
+      if (element instanceof HTMLScriptElement && element.onerror) {
+        setTimeout(() => {
+          (element.onerror as any)('Script load error');
+        }, 0);
+      }
+      return element;
+    });
+
+  await loader.initializeExtensions();
+
+  expect(infoSpy).toHaveBeenCalledWith(
+    expect.stringContaining('1 of 2 extension(s) failing'),
+  );
+  expect(loader.getExtension('good-ext')).toBeDefined();
+  expect(loader.getExtension('broken-ext')).toBeUndefined();
+
+  infoSpy.mockRestore();
+  appendChildSpy.mockRestore();
+});
+
+test('each extension gets an isolated getContext via module federation custom 
scope', async () => {
+  const loader = ExtensionsLoader.getInstance();
+
+  // Capture the scoped @apache-superset/core instance each container receives
+  const capturedCoreModules: Array<any> = [];
+
+  const makeContainer = () => ({
+    init: jest.fn().mockImplementation(async (scope: any) => {

Review Comment:
   **Suggestion:** Type the `scope` argument with an explicit module-federation 
scope interface rather than `any`. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The callback parameter is typed as `any`, which is exactly what the custom 
rule disallows in changed TypeScript code.
   </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=80b8137f6347478eb35b976330d3d57b&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=80b8137f6347478eb35b976330d3d57b&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/ExtensionsLoader.test.ts
   **Line:** 260:260
   **Comment:**
        *Custom Rule: Type the `scope` argument with an explicit 
module-federation scope 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%2F39171&comment_hash=31873b271f1a0119ac0e45ee07196eeefd2e593e4d664b9d4711c312b9b015c0&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39171&comment_hash=31873b271f1a0119ac0e45ee07196eeefd2e593e4d664b9d4711c312b9b015c0&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