Skip to content

Bethany/guard malformed lesson summary - #76215

Draft
bethanyaconnor wants to merge 2 commits into
stagingfrom
bethany/guard-malformed-lesson-summary
Draft

bethanyaconnor wants to merge 2 commits into
stagingfrom
bethany/guard-malformed-lesson-summary

Conversation

@bethanyaconnor

Copy link
Copy Markdown
Contributor

Validation

  • Vetted PR content for length, code quality, comment clarity and readability.
  • Vetted PR description for length, accuracy, clarity, and readability.

Authorship

Deployment notes

Privacy and security


For further PR guidelines, see PULL_REQUEST_GUIDELINES.md

bethanyaconnor and others added 2 commits October 19, 2026 15:19
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

No deployments
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