Skip to content

fix(docker): playground config type + monitor websocket auth dep - #2063

Merged
ntohidi merged 1 commit into
unclecode:developfrom
Pitchfork-and-Torch:fix/docker-playground-type-and-monitor-ws
Jul 11, 2026
Merged

ntohidi merged 1 commit into
unclecode:developfrom
Pitchfork-and-Torch:fix/docker-playground-type-and-monitor-ws

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown
Contributor

Summary

Two Docker UI server bugs with confirmed root causes on develop.

Fixes #2059 — Playground Advanced Config always 400

pyConfigToJson() POSTed { code } to /config/dump, but the server requires type (CrawlerRunConfig | BrowserConfig). Every custom Advanced Config failed with:

{"detail":"type must be 'CrawlerRunConfig' or 'BrowserConfig'"}

Change: send type from #cfg-type with the code.

Also tightens the related stream-path follow-up from the issue:

  • Fallback minimal config uses dump-shaped { type, params: { stream: true } }
  • shouldUseStream() reads both crawler_config.params.stream and top-level crawler_config.stream

Fixes #2060 — Dashboard /monitor/ws 500

app.include_router(monitor_router, dependencies=[Depends(token_dep)])

token_dep is HTTP Request-only. FastAPI applies router-level deps to the WebSocket route; inject fails with:

TypeError: _principal() missing 1 required positional argument: 'request'

The WS handler already documents that AuthGateMiddleware owns auth; destructive routes keep Depends(require_admin).

Change: app.include_router(monitor_router) without the HTTP-only dependency.

Test plan

  • Playground: expand Advanced Config (default CrawlerRunConfig), Run → /config/dump returns 200 and crawl succeeds
  • Playground: switch type to BrowserConfig template → dump + run succeed
  • Playground: intentional bad Python in Advanced Config still surfaces config error
  • Dashboard: with valid token, /monitor/ws upgrades (101) and streams health/requests JSON
  • Dashboard: unauthenticated WS still rejected by middleware
  • Monitor admin actions still require admin scope

Notes

  • Targets develop (collaborator convention).
  • Minimal, focused diff: 2 files.

Playground Advanced Config always 400'd because /config/dump requires
type but pyConfigToJson only sent code. Include #cfg-type, align stream
fallback with dump shape, and teach shouldUseStream both nestings.

Monitor dashboard WS /monitor/ws 500'd because router-level token_dep is
HTTP Request-only and cannot inject into WebSocket scopes. Auth remains
on AuthGateMiddleware; admin routes keep require_admin.

Fixes #2059
Fixes #2060
@ntohidi
ntohidi merged commit a8ab4ce into unclecode:develop Jul 11, 2026
@ntohidi

ntohidi commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix, @Pitchfork-and-Torch.

ntohidi added a commit that referenced this pull request Jul 11, 2026
The router-level token_dep was intentionally removed (PR #2063) because
it broke WebSocket upgrades. Update the structural test to assert the
dependency is absent — auth is enforced by AuthGateMiddleware.
@Pitchfork-and-Torch
Pitchfork-and-Torch deleted the fix/docker-playground-type-and-monitor-ws branch September 6, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants