Skip to content

Raise on unparseable submissions so they surface as 422 - #13

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

m-messer merged 4 commits into
mainfrom
feature/invalid-submission-422

Conversation

@m-messer

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

Copy link
Copy Markdown
Member

Summary

Responses that can't be parsed (e.g. "A n ") used to come back as a 200 with is_correct: false and parse_error feedback. Because the function returned normally, the new invalid-submission handling in lf_toolkit and shimmy never ran.

  • FeedbackException now subclasses ValueError, and evaluation_function no longer catches it. lf_toolkit maps a ValueError from the handler to an invalid-submission error, and shimmy returns that as 422 VALIDATION_ERROR.
  • If the answer (reference solution) can't be parsed, the function now raises RuntimeError. That's a problem with the task setup, not the student's input, so it comes back as a 500.
  • preview_function hasn't changed: it still catches FeedbackException and returns inline feedback.

Behaviour change

A student who submits something unparseable now gets an error response instead of a graded result with parse_error feedback.

Dependencies

Testing

  • Replaced test_returns_is_correct_false_not_parseable with tests checking that an unparseable response raises ValueError and an unparseable answer raises a non-ValueError.
  • pytest evaluation_function: 20 passed, plus 2 subtests.

🤖 Generated with Claude Code

m-messer and others added 3 commits October 5, 2026 18:40
Unparseable responses previously returned a 200 with is_correct=False and
parse_error feedback, so lf_toolkit's invalid-submission handling never
fired. FeedbackException now subclasses ValueError and is no longer caught,
so lf_toolkit reports it as an invalid submission (422).

An unparseable answer is a fault in the task rather than the student's
submission, so it raises RuntimeError instead and is reported as a 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pins lf_toolkit to toolkit-python 9d89276 (feature/invalid-submission-error),
which maps a ValueError raised by the evaluation function to a JSON-RPC 422
error, so unparseable submissions can be tested end to end on staging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
toolkit-python v1.2.0 and shimmy main now include the invalid-submission
(422) handling, so switch from the test builds to the released toolkit
tag and the edge base image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-messer
m-messer merged commit abf98c9 into main Oct 5, 2026
1 check passed
@m-messer
m-messer deleted the feature/invalid-submission-422 branch October 5, 2026 18:16
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