Skip to content

Report unprocessable submissions as invalid-submission errors (422) - #14

Merged
m-messer merged 2 commits into
mainfrom
feature/invalid-submission-error
Oct 5, 2026
Merged

m-messer merged 2 commits into
mainfrom
feature/invalid-submission-error

Conversation

@m-messer

@m-messer m-messer commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Lets an evaluation function tell the caller that it can't process a submission (e.g. an unparseable expression), so shimmy can return 422 instead of a 200 or a 500.

  • Handler._call_user_handler turns a ValueError raised by a user handler into InvalidSubmissionError. Other exceptions are handled as before.
  • RPC transport: JsonRpcHandler returns InvalidSubmissionError as a JSON-RPC error with code 422 (INVALID_SUBMISSION_CODE).
  • File transport: FileHandler returns {"error": {"message": ..., "code": "INVALID_SUBMISSION"}}. Other errors are now {"error": {"message": ...}} instead of a bare string, which is the shape shimmy reads.
  • Adds tests for the RPC and file handlers.

⚠️ Behaviour change for all evaluation functions

Any ValueError that escapes an evaluation function, preview or chat handler is now reported as an invalid submission (422), not a generic error. Functions that raise ValueError for anything other than bad input should raise a different exception type.

Related

🤖 Generated with Claude Code

tests/io/tcp_server_test.py imports lf_toolkit.io.tcp_server, which only
exists on feature/tcp, so test collection failed on this branch. The tests
belong with that branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-messer
m-messer merged commit df5efa3 into main Oct 5, 2026
2 checks passed
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