Report unprocessable submissions as invalid-submission errors (422) - #14
Merged
Merged
Conversation
…ler and FileHandler
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_handlerturns aValueErrorraised by a user handler intoInvalidSubmissionError. Other exceptions are handled as before.JsonRpcHandlerreturnsInvalidSubmissionErroras a JSON-RPC error with code422(INVALID_SUBMISSION_CODE).FileHandlerreturns{"error": {"message": ..., "code": "INVALID_SUBMISSION"}}. Other errors are now{"error": {"message": ...}}instead of a bare string, which is the shape shimmy reads.Any
ValueErrorthat escapes an evaluation function, preview or chat handler is now reported as an invalid submission (422), not a generic error. Functions that raiseValueErrorfor anything other than bad input should raise a different exception type.Related
422code and the fileINVALID_SUBMISSIONcode to an HTTP 422 response: Return 422 when the evaluation function rejects a submission shimmy#38.🤖 Generated with Claude Code