apache / apache/superset

Embedded dashboard: 'Failed to query feature flag' console errors due to missing initFeatureFlags()

Open
#37,310 3 comments 0 reactions 1 assignee Claimed by @YuriyKrasilnikov View on GitHub
embedded validation:required
Dominant language
Python
Stars
74.8k
Forks
18.3k
Avg merge
2d 5h
Merged PRs (30d)
685

Description

### Bug description

When using embedded dashboards with guest tokens, the browser console shows multiple errors:

```
Failed to query feature flag ENABLE_JAVASCRIPT_CONTROLS
```

**Root cause:** The `embedded/index.tsx` entry point does not call `initFeatureFlags()`, so `window.featureFlags` remains `undefined`. When `isFeatureEnabled()` is called, it throws an error trying to access a property on `undefined`.

**In regular mode** (`preamble.ts:81`):
```typescript
initFeatureFlags(bootstrapData.common.feature_flags);
```

**In embedded mode** (`embedded/index.tsx`): No initialization of feature flags.

**Steps to reproduce:**
1. Create an embedded dashboard with guest token
2. Open the embedded dashboard in an iframe
3. Open browser console (F12)
4. See multiple "Failed to query feature flag" errors

**Expected behavior:**
No console errors. Feature flags should be initialized from bootstrap data in embedded mode.

**Suggested fix:**
Add `initFeatureFlags(bootstrapData.common.feature_flags)` to `embedded/index.tsx` after `getBootstrapData()`, similar to `preamble.ts`.

### Screenshots/recordings

N/A - console errors are text-based

### Superset version

6.0.0

### Python version

3.12

### Node version

18 or greater

### Browser

Chrome

### Additional context

Feature flags enabled:
- `EMBEDDED_SUPERSET: true`
- `EMBEDDABLE_CHARTS: true`

The errors do not break functionality but clutter the console and may confuse developers debugging embedded dashboards.

Related code locations:
- `superset-frontend/src/embedded/index.tsx` - missing initialization
- `superset-frontend/src/preamble.ts:81` - correct initialization
- `superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts:106` - where error is logged

### Checklist

- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.