Skip to content

Commit a8ab4ce

Browse files
authored
Merge pull request #2063 from Pitchfork-and-Torch/fix/docker-playground-type-and-monitor-ws
fix(docker): playground config type + monitor websocket auth dep
2 parents 202ff71 + 1a28980 commit a8ab4ce

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

deploy/docker/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,12 @@ def _config_from_json(data: dict) -> dict:
482482
app.include_router(init_job_router(redis, config, token_dep))
483483

484484
# ── monitor router ──────────────────────────────────────────
485+
# Do not attach token_dep at router level: it is HTTP Request-only and breaks
486+
# the WebSocket upgrade on /monitor/ws (TypeError: _principal() missing 'request').
487+
# AuthGateMiddleware already authenticates HTTP + WS; destructive monitor
488+
# actions keep their own Depends(require_admin).
485489
from monitor_routes import router as monitor_router
486-
app.include_router(monitor_router, dependencies=[Depends(token_dep)])
490+
app.include_router(monitor_router)
487491

488492
logger = logging.getLogger(__name__)
489493

deploy/docker/static/playground/index.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,13 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
563563
const code = cm.getValue().trim();
564564
if (!code) return {};
565565

566+
// Server requires `type` alongside `code` (CrawlerRunConfig | BrowserConfig).
567+
// The UI already tracks this in #cfg-type; omitting it always 400s Advanced Config.
568+
const cfgType = document.getElementById('cfg-type').value;
566569
const res = await authFetch('/config/dump', {
567570
method: 'POST',
568571
headers: { 'Content-Type': 'application/json' },
569-
body: JSON.stringify({ code }),
572+
body: JSON.stringify({ type: cfgType, code }),
570573
});
571574

572575
const statusEl = document.getElementById('cfg-status');
@@ -652,9 +655,12 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
652655
// Detect if stream is requested inside payload
653656
function shouldUseStream(payload) {
654657
const toBool = (v) => v === true || (typeof v === 'string' && v.toLowerCase() === 'true');
655-
const fromCrawler = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
658+
// Successful /config/dump returns { type, params: { stream, ... } }
659+
const fromCrawlerParams = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
660+
// Fallback / minimal shapes may set stream at the crawler_config top level
661+
const fromCrawlerTop = payload && payload.crawler_config && payload.crawler_config.stream;
656662
const direct = payload && payload.stream;
657-
return toBool(fromCrawler) || toBool(direct);
663+
return toBool(fromCrawlerParams) || toBool(fromCrawlerTop) || toBool(direct);
658664
}
659665

660666
// Main run function
@@ -676,8 +682,8 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
676682
const streamFlag = /stream\s*=\s*True/i.test(codeText);
677683
const isCrawlEndpoint = document.getElementById('endpoint').value === 'crawl';
678684
if (isCrawlEndpoint && streamFlag) {
679-
// Fallback: proceed with minimal config only for stream
680-
advConfig = { crawler_config: { stream: true } };
685+
// Fallback: minimal dump-shaped config so shouldUseStream + server load agree
686+
advConfig = { crawler_config: { type: 'CrawlerRunConfig', params: { stream: true } } };
681687
} else {
682688
updateStatus('error');
683689
document.querySelector('#response-content code').textContent =

0 commit comments

Comments
 (0)