Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions superset-frontend/src/extensions/ExtensionsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import {
FeatureFlag,
SupersetClient,
isFeatureEnabled,
logging,
} from '@superset-ui/core';
import { SupersetClient, logging } from '@superset-ui/core';
import type { contributions, core } from '@apache-superset/core';
import { ExtensionContext } from '../core/models';

Expand Down Expand Up @@ -62,9 +57,6 @@ class ExtensionsManager {
* @throws Error if initialization fails.
*/
public async initializeExtensions(): Promise<void> {
if (!isFeatureEnabled(FeatureFlag.EnableExtensions)) {
return;
}
const response = await SupersetClient.get({
endpoint: '/api/v1/extensions/',
});
Comment on lines 59 to 62
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unconditional API call when extensions disabled category Functionality

Tell me more
What is the issue?

The initializeExtensions method now unconditionally makes an API call to fetch extensions, even when the EnableExtensions feature flag is disabled.

Why this matters

This will cause unnecessary network requests and potential processing of extension data when extensions are disabled, contradicting the developer's intent to avoid extension-related operations when the flag is off.

Suggested change ∙ Feature Preview

The feature flag check should be moved to the caller (ExtensionsStartup) or restored in this method to prevent the API call when extensions are disabled:

public async initializeExtensions(): Promise<void> {
  if (!isFeatureEnabled(FeatureFlag.EnableExtensions)) {
    return;
  }
  const response = await SupersetClient.get({
    endpoint: '/api/v1/extensions/',
  });
  // ... rest of the method
}
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the check was moved one level up, so that this is never triggered if the flag is unset.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thank you for clarifying. The higher-level check addresses the concern about unnecessary API calls when extensions are disabled.

Expand Down
17 changes: 9 additions & 8 deletions superset-frontend/src/extensions/ExtensionsStartup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { useEffect, useState } from 'react';
// eslint-disable-next-line no-restricted-syntax
import * as supersetCore from '@apache-superset/core';
import { logging } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled, logging } from '@superset-ui/core';
import {
authentication,
core,
Expand Down Expand Up @@ -75,14 +75,15 @@ const ExtensionsStartup = () => {
};

// Initialize extensions
try {
ExtensionsManager.getInstance().initializeExtensions();
logging.info('Extensions initialized successfully.');
} catch (error) {
logging.error('Error setting up extensions:', error);
} finally {
setInitialized(true);
if (isFeatureEnabled(FeatureFlag.EnableExtensions)) {
try {
ExtensionsManager.getInstance().initializeExtensions();
logging.info('Extensions initialized successfully.');
} catch (error) {
logging.error('Error setting up extensions:', error);
}
}
setInitialized(true);
}, [initialized, userId]);

return null;
Expand Down
Loading