-
Notifications
You must be signed in to change notification settings - Fork 3
Handle invalid JSON in ValidateRepoHandler with 400 #54
Copy link
Copy link
Open
Description
Summary
ValidateRepoHandler.post() calls json.loads(self.request.body) without guarding JSONDecodeError, causing a 500 on malformed request payloads.
Why this matters
Invalid client input should produce deterministic 4xx responses, not internal server errors.
Current behavior
Malformed JSON can bubble up as an unhandled exception and return 500.
Expected behavior
Malformed JSON should return 400 Bad Request with a clear error message.
Proposed fix
- Wrap JSON parsing with
try/except (json.JSONDecodeError, ValueError). - Return
HTTPError(400, "Invalid JSON body")(consistent with other handlers). - Add tests for malformed payload handling.
Acceptance criteria
- Malformed JSON returns 400.
- Valid payload behavior is unchanged.
- Tests cover invalid and valid cases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels