Return 404 on restore when instance not found#224
Conversation
Map instances.ErrNotFound to 404 in RestoreInstance, matching the existing pattern used by ForkInstance and other handlers in this file. Previously this surfaced as a 500.
Monitoring PlanThis is a low-risk HTTP status code fix: What I'll watch for: Since Hypeman doesn't have trace/log tables in the Firetiger data lake, the primary health signals are invocation spawn success rates via Status updates will be posted automatically on this PR as monitoring progresses. |
Summary
Map
instances.ErrNotFoundto404in theRestoreInstancehandler. Previously this surfaced as500 internal_errorbecause the handler'sswitchonly checked forErrInvalidState, with everything else falling through to the default 500 path.This matches the existing pattern in
ForkInstanceand the other handlers in the same file. TheRestoreInstance404JSONResponsetype is already declared inopenapi.yaml(line 2287) and generated intolib/oapi/oapi.go— no regen needed.Observed in production: ~2 cases over the last 18h, all on `POST /instances/{id}/restore` with the error attribute `instance not found`. These should be 404, not 500.
Test plan
Note
Low Risk
Low risk: only adjusts HTTP error mapping in the
RestoreInstancehandler, with no changes to restore behavior or state transitions.Overview
POST /instances/{id}/restorenow mapsinstances.ErrNotFoundto a404 not_foundresponse instead of falling through to the generic500 internal_errorpath. Other error mappings (e.g.,ErrInvalidState→ 409) are unchanged.Reviewed by Cursor Bugbot for commit b7082b5. Bugbot is set up for automated code reviews on this repo. Configure here.