Repository navigation
Bethany/guard malformed lesson summary - #76215
Draft
bethanyaconnor wants to merge 2 commits into
Draft
bethanyaconnor wants to merge 2 commits into
bethanyaconnor wants to merge 2 commits into
Conversation
A stored lesson summary whose lesson_beats were {name: ...} objects
rather than strings crashed the Lesson Materials page with React error
#31, since each beat is rendered directly as a child.
Both places that render a summary now go through parseLessonSummary,
which checks its shape before any of it reaches JSX. A malformed
summary, including one missing any of its four fields, is reported to
Sentry with its record id and treated as absent: Lesson Materials hides
the summary panel, and the AI TA lesson summary screen shows its
existing no-summary message.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The OpenAI request for a lesson summary sends a JSON schema without
strict mode, so the model treats it as a hint; one summary came back
with lesson_beats as {name: ...} objects and was saved as is. Check
each response against the schema and raise
OpenaiLessonSummaryInvalidResponse rather than save output the
frontend cannot render. Extra keys are allowed; missing fields and
wrong types are not.
The response is parsed before validation because json-schema treats a
string that is not valid JSON as a URI and tries to open it.
The two tests of the request schema never asserted anything: their
assertions sat in a block that HTTParty.stubs ignores. They now
capture the request body and assert on it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Validation
Authorship
Deployment notes
Privacy and security
For further PR guidelines, see PULL_REQUEST_GUIDELINES.md