Skip to content

Comments

fix: return 404 instead of 500 for stale scanner UUIDs#291

Open
revmischa wants to merge 2 commits intomeridianlabs-ai:mainfrom
METR:fix/hawk-14-scanner-input-keyerror
Open

fix: return 404 instead of 500 for stale scanner UUIDs#291
revmischa wants to merge 2 commits intomeridianlabs-ai:mainfrom
METR:fix/hawk-14-scanner-input-keyerror

Conversation

@revmischa
Copy link
Contributor

@revmischa revmischa commented Feb 18, 2026

Summary

  • Wraps get_field() calls in the scanner_input endpoint with try/except KeyError to return a proper 404 instead of an unhandled 500
  • Root cause: when a scan is re-run, UUIDs are regenerated via shortuuid.uuid(). Users with stale browser tabs still reference old UUIDs, causing KeyError in parquet lookup

Changes

  • src/inspect_scout/_view/_api_v2_scans.py: Added try/except KeyError around get_field() calls, returning HTTP 404 with a descriptive message
  • tests/view/test_api_v2_scanner_input.py: Added tests for unknown UUID (404), unknown scanner (404), and valid UUID (200 with input + header)

Test plan

  • ruff check passes
  • ruff format passes
  • mypy src passes
  • pytest tests/view/test_api_v2_scanner_input.py — blocked by inspect_ai dependency mismatch (CompactionEvent missing); affects all tests in repo, not specific to this change

🤖 Generated with Claude Code

When a scan is re-run, UUIDs are regenerated. Users with stale browser
tabs would get unhandled KeyError (500) when fetching scanner input for
old UUIDs. Wrap get_field calls in try/except KeyError to return a
proper 404.

Fixes Sentry HAWK-14.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@revmischa revmischa marked this pull request as ready for review February 18, 2026 20:13
@dragonstyle dragonstyle requested a review from epatey February 19, 2026 00:43
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.

1 participant