Repository navigation
feat(websocket): support JWT secret rotation - #43524
Conversation
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| const acceptedSecrets = [opts.jwtSecret, opts.previousJwtSecret].filter( | ||
| secret => secret.length > 0, | ||
| ); |
There was a problem hiding this comment.
Suggestion: Configuration loaded from JSON is not runtime-validated, so a null previousJwtSecret bypasses the optional startup check and then causes every upgrade attempt to throw when the filter accesses secret.length. Normalize non-string values to an empty secret or reject the configuration before requests are handled. [null pointer]
Severity Level: Major ⚠️
- ❌ All WebSocket upgrades fail with malformed rotation configuration.
- ❌ Realtime browser updates cannot establish socket connections.
- ⚠️ Polling remains available as the documented correctness backstop.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-websocket/src/index.ts
**Line:** 504:506
**Comment:**
*Null Pointer: Configuration loaded from JSON is not runtime-validated, so a null `previousJwtSecret` bypasses the optional startup check and then causes every upgrade attempt to throw when the filter accesses `secret.length`. Normalize non-string values to an empty secret or reject the configuration before requests are handled.
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|
The flagged issue regarding a potential null pointer when Here is a concise fix for the configuration loading logic: // Ensure previousJwtSecret is a string, defaulting to an empty string if null/undefined
config.previousJwtSecret = config.previousJwtSecret || '';I have checked the PR comments and there are no other actionable suggestions in the provided context. Would you like me to fetch all comments to validate and implement fixes for any remaining issues? superset-websocket/src/index.ts |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## gaq-to-gtf #43524 +/- ##
==============================================
+ Coverage 78.89% 78.92% +0.03%
==============================================
Files 2884 2889 +5
Lines 165429 165672 +243
Branches 38218 38153 -65
==============================================
+ Hits 130514 130759 +245
- Misses 32444 32454 +10
+ Partials 2471 2459 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Bito Automatic Review Failed - Technical Failure |
SUMMARY
Adds verify-only websocket JWT secret rotation support to the
superset-websocketservice. The Flask app continues minting realtime cookies withWEBSOCKET_JWT_SECRET. The Node websocket service validates against its active verifier secret (JWT_SECRET/jwtSecret) and, during rotation, an optional previous verify-only key (PREVIOUS_JWT_SECRET/previousJwtSecret). The previous key is service-local websocket config; the Flask app does not need it because it only mints new tokens with the active secret.This also renames the Superset-side enable flag from
ENABLE_WEBSOCKETtoWEBSOCKET_ENABLEso the websocket config surface is consistentlyWEBSOCKET_*before the feature branch merges.The frontend realtime client now treats duplicate initialization with the same websocket config as idempotent. This avoids closing and replacing an already-active socket during bootstrap, which otherwise produces noisy browser console failures even though the replacement socket succeeds.
The websocket server now emits a debug log after forwarding a message to local sockets. The log includes the outbound browser channel and socket count, but not the payload.
The async chart-data middleware also stays idle until a chart request actually returns HTTP 202. Websocket mode still keeps polling as the correctness fallback while waiting for async tasks, but it no longer performs a startup
/api/v1/task/status_changesrequest when there is no async chart activity.This now also fixes chained GTF task execution for async chart-data queries. Dependent tasks are enqueued immediately and wait for prerequisite tasks before claiming execution. A dependent worker can load a prerequisite as
pendingwhile another worker later commits it assuccess; without a forced refresh, SQLAlchemy can return the stale identity-map object forever and the dependent task never reaches the executor body.BaseDAOnow supports an opt-inforce_fetchquery mode, andTaskDAOenables it by default because task rows are cross-worker mutable state.Chained chart-data tasks also carry the output metadata needed by contribution-mode queries. Contribution totals normalization runs on the
QueryContextbefore anyquery_cache_keyis computed. The totals task publishes its actual DATA cache key in task payload; dependent contribution tasks read prerequisite payloads viaTaskContext.get_dependency_payloads()and use that key to inject totals. Contribution post-processing without a synthetic totals query, such as pie-chart share calculations, remains local and does not read dependency payloads. This intentionally exposes only dependency payload dictionaries, not full task ORM objects, keeping the internal DAG API limited while still allowing tasks to pass small pieces of context forward.One compatibility compromise remains here: serialized query payloads can carry an internal
preserve_null_row_limitmarker so a normalized synthetic totals query withrow_limit: nullrehydrates with the same cache key, while ordinary external/query-contextrow_limit: nullvalues keep the previous default-limit behavior. This is not ideal API shape, but it keeps the GAQ-to-GTF bridge narrow and avoids regressions in the legacy query-context interface. The future Semantic Query based interface should represent this directly instead of inheriting this shortcoming.The docs now spell out the Kubernetes deployment model: run
superset-websocketas a horizontally scalable, stateless Deployment/Service, not a singleton. Each browser socket is owned by exactly one replica after HTTP Upgrade; Redis Pub/Sub events are broadcast to all websocket replicas, and each replica fans out only to matching sockets it owns locally. Sticky sessions are not required, and polling remains the correctness backstop for reconnects/drains.A separate
WEBSOCKET_K8S_OPERATOR_REQUIREMENTS.mdcaptures the operator requirements for ingress, auth config, secret rotation, short-lived sockets, draining, Redis, and HPA/scaling tradeoffs.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
From the repo root:
From
superset-frontend/:npm run test -- src/middleware/realtime.test.ts src/middleware/asyncEvent.test.tsAlso run:
ADDITIONAL INFORMATION