Fix missing request context (cookies/headers) in WebSocket callbacks#3815
Fix missing request context (cookies/headers) in WebSocket callbacks#3815i-murray wants to merge 4 commits into
Conversation
Propagate cookies, headers, args, path, remote, and origin from the WebSocket handshake onto the callback context in create_ws_context, mirroring the HTTP path. This fixes auth helpers (e.g. dash_enterprise_auth.get_user_data) failing over the WebSocket transport because callback_context.cookies/headers were empty.
|
We have another PR #3819 that uses set_context_request on the fastapi part for the same effect, I think we need both solution consolidated. |
Re: #3819: It addresses a different bug. #3819 fixes when a non-Dash path falls through to the FastAPI catch-all route (fixes #3812) by wrapping the Re: consolidating the mechanism: I've refactored so WebSocket callbacks now reuse the same request-context path as HTTP callbacks instead of building a parallel dict:
Tests: added unit coverage for the adapter/threading seam and end-to-end tests for both FastAPI and Quart asserting cookies/headers are visible inside a WebSocket callback. |
Populate callback_context request metadata (cookies/headers/args/path/ remote/origin) for WebSocket callbacks the same way as HTTP callbacks, via a shared populate_request_metadata helper and an activate_request seam (FastAPI uses set_current_request; Quart uses a handshake snapshot). Adds unit and end-to-end tests for FastAPI and Quart.
|



Propagate cookies, headers, args, path, remote, and origin from the WebSocket handshake onto the callback context in create_ws_context, mirroring the HTTP path. This fixes auth helpers (e.g.
dash_enterprise_auth.get_user_data) failing over the WebSocket transport because callback_context.cookies/headers were empty.Closes #3814
Contributor Checklist
optionals
CHANGELOG.md