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


##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -67,9 +70,28 @@ const ExtensionsStartup: React.FC<{ children?: 
React.ReactNode }> = ({
       views,
     };
 
+    // Load extensions without blocking the initial render (see #40915);
+    // surface any load failure as a warning toast instead of failing silently.
     if (isFeatureEnabled(FeatureFlag.EnableExtensions)) {
-      ExtensionsLoader.getInstance().initializeExtensions();
+      ExtensionsLoader.getInstance()
+        .initializeExtensions()
+        .then(() =>
+          supersetCore.utils.logging.info(
+            'Extensions initialized successfully.',
+          ),
+        )
+        .catch(error => {
+          supersetCore.utils.logging.error(
+            'Error setting up extensions:',
+            error,
+          );
+          dispatch(
+            addWarningToast(t('Extensions failed to load: %s', String(error))),
+          );
+        });

Review Comment:
   **Suggestion:** This code assumes `initializeExtensions()` rejects whenever 
an extension fails to load, but `ExtensionsLoader.initializeExtension()` 
currently catches and swallows per-extension load errors, so the promise can 
still resolve with partial failures. That means this success branch can run 
even when some extensions are broken, and the warning toast path never 
executes. Make the loader propagate extension init failures (or return a 
failure summary and handle it here) so users are actually notified when any 
extension fails. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Extensions with failing remote entries silently fail to load.
   - ⚠️ Users see success log despite missing extension features.
   - ⚠️ Warning toast never fires for partial extension failures.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Start the Superset frontend so that `App` renders `ExtensionsStartup` (see
   `superset-frontend/src/views/App.tsx:17-19`, where `<ExtensionsStartup>` 
wraps
   `<AppContent />`).
   
   2. Ensure the extensions feature flag is enabled so `EnableExtensions` is 
true; when a
   user session is present (`userId` not null), the `useEffect` in
   `superset-frontend/src/extensions/ExtensionsStartup.tsx:53-95` executes and, 
at lines
   75-77, calls `ExtensionsLoader.getInstance().initializeExtensions()` if
   `isFeatureEnabled(FeatureFlag.EnableExtensions)` is true.
   
   3. Configure the backend `/api/v1/extensions/` endpoint to return at least 
one extension
   whose `remoteEntry` URL will fail to load (for example, a 404 or invalid 
host) — this
   value is consumed by `SupersetClient.get` in
   `superset-frontend/src/extensions/ExtensionsLoader.ts:59-68`, which then 
calls
   `initializeExtension` for each `Extension` in the `result` array.
   
   4. When the browser tries to load that broken `remoteEntry`, `loadModule` in
   `ExtensionsLoader.loadModule`
   (`superset-frontend/src/extensions/ExtensionsLoader.ts:112-144`) rejects; 
this rejection
   is caught inside `initializeExtension` at
   `superset-frontend/src/extensions/ExtensionsLoader.ts:93-105`, which logs 
`Failed to
   initialize extension ...` but does not rethrow, so `Promise.all` in 
`initializeExtensions`
   still resolves and logs `logging.info('Extensions initialized 
successfully.')` at line 74.
   As a result, the `initializeExtensions()` promise returned to 
`ExtensionsStartup`
   resolves, the `.then` branch at `ExtensionsStartup.tsx:78-81` runs, and the 
`.catch` at
   `ExtensionsStartup.tsx:83-90` (which would dispatch `addWarningToast(...)`) 
never
   executes, even though at least one extension failed to load and its 
contributions are
   missing.
   ```
   </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=88a4bef2a2c74b828416a4f3c3335b88&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=88a4bef2a2c74b828416a4f3c3335b88&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:** 76:91
   **Comment:**
        *Api Mismatch: This code assumes `initializeExtensions()` rejects 
whenever an extension fails to load, but 
`ExtensionsLoader.initializeExtension()` currently catches and swallows 
per-extension load errors, so the promise can still resolve with partial 
failures. That means this success branch can run even when some extensions are 
broken, and the warning toast path never executes. Make the loader propagate 
extension init failures (or return a failure summary and handle it here) so 
users are actually notified when any extension fails.
   
   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%2F41285&comment_hash=fa9dd72aab9e4cc8c96ab3ba44e272f0899946cdcc333a6f8ad48febb5ce9607&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41285&comment_hash=fa9dd72aab9e4cc8c96ab3ba44e272f0899946cdcc333a6f8ad48febb5ce9607&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