{"record":{"id":"babc8eee7674dc89","repo":"abi/screenshot-to-code","slug":"active-session-e-active-session-name-r-is-pinned","errorCode":null,"errorMessage":"Active session {e.active_session.name!r} is pinned to set {e.active_session.eval_set!r}. Start a new session for set {request.set_name!r} first (POST /eval-sessions).","messagePattern":"Active session (.+?) is pinned to set (.+?)\\. Start a new session for set (.+?) first \\(POST /eval-sessions\\)\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"backend/routes/evals.py","lineNumber":138,"sourceCode":"    \"\"\"Validate the requested set and resolve the session + per-model skips.\"\"\"\n    if not request.set_name:\n        return None, None, {}\n    try:\n        set_info = eval_sets.get_set(request.set_name)\n    except eval_sets.InvalidSetNameError as e:\n        raise HTTPException(status_code=400, detail=str(e))\n    except eval_sets.EvalSetNotFoundError:\n        raise HTTPException(\n            status_code=404, detail=f\"Eval set not found: {request.set_name}\"\n        )\n    if set_info.image_count == 0:\n        raise HTTPException(\n            status_code=400, detail=f\"Eval set {request.set_name!r} has no images\"\n        )\n    try:\n        session = eval_sessions.resolve_session_for_run(request.set_name)\n    except eval_sessions.SessionSetMismatchError as e:\n        raise HTTPException(\n            status_code=400,\n            detail=(\n                f\"Active session {e.active_session.name!r} is pinned to set \"\n                f\"{e.active_session.eval_set!r}. Start a new session for set \"\n                f\"{request.set_name!r} first (POST /eval-sessions).\"\n            ),\n        )\n    skip_per_model: Dict[str, set[str]] = {}\n    if request.diff_mode:\n        for model in request.models:\n            skip_per_model[model] = eval_sessions.completed_eval_inputs(\n                session.session_id, model, str(request.stack)\n            )\n    return request.set_name, session, skip_per_model\n\n\nclass OpenAIInputCompareRequest(BaseModel):\n    left_json: str","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/evals.py#L120-L156","documentation":"400 raised inside _resolve_set_run in backend/routes/evals.py:138 when eval_sessions.resolve_session_for_run raises SessionSetMismatchError: there is an active eval session, but it is pinned to a different eval set. Sessions are set-scoped, so running a new set requires a fresh session. The detail names the active session, its pinned set, and the required remedy (POST /eval-sessions).","triggerScenarios":"Starting a run with set_name=B while the active session was created for set_name=A.","commonSituations":"User finishes work on one set and switches the set dropdown without starting a new session; long-lived frontend keeps an old active session across set changes.","solutions":["POST /eval-sessions with the new set to start a fresh session, then re-issue the run request.","Or switch the run back to the set the active session is pinned to.","In the UI, auto-create a new session whenever the selected set differs from the active session's set."],"exampleFix":"// before\nawait post('/run_evals_stream', { set_name: newSetName, ... });\n\n// after\nif (activeSession?.eval_set !== newSetName) {\n  activeSession = await post('/eval-sessions', { eval_set: newSetName });\n}\nawait post('/run_evals_stream', { set_name: newSetName, ... });","handlingStrategy":"validation","validationCode":"if (activeSession && activeSession.eval_set !== requestedSet) {\n  activeSession = await fetch('/eval-sessions', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ eval_set: requestedSet }),\n  }).then(r => r.json());\n}","typeGuard":null,"tryCatchPattern":"const res = await fetch('/run_evals_stream', ...);\nif (res.status === 400 && detail.includes('pinned to set')) {\n  await createNewSession(requestedSet);\n  await retryRun();\n}","preventionTips":["Track the active session's eval_set in client state and compare before every run.","Switching sets in the UI should always imply creating a new session."],"tags":["http-400","eval-sessions","eval-sets","state-management","fastapi"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}