Skip to content

Gate DEBUG output validation to serializer-derived viewsets#14811

Merged
rtibbles merged 1 commit into
learningequality:developfrom
rtibbles:gate-debug-validation
Jun 9, 2026
Merged

Gate DEBUG output validation to serializer-derived viewsets#14811
rtibbles merged 1 commit into
learningequality:developfrom
rtibbles:gate-debug-validation

Conversation

@rtibbles

@rtibbles rtibbles commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

The DEBUG-mode output validator in ValuesViewset.serialize() ran against every viewset. Legacy viewsets that pair an explicit values tuple with a write-oriented serializer_class were validated against the wrong contract, so they 500ed in dev mode. Validation is now gated to viewsets whose values are derived from their serializer; legacy explicit-values viewsets skip it.

References

Follow-up to #14327, which introduced the DEBUG-mode output validation.

Reviewer guidance

To reproduce: on develop, run the dev server and request any endpoint backed by a legacy viewset that defines both values and serializer_class (e.g. /api/lessons/lesson/) — it 500s with a ValueError about missing/unexpected fields. On this branch the same request succeeds.

The existing drift tests in TestDevModeSafeguards cover that serializer-derived viewsets are still validated.

AI usage

Implemented with Claude Code: it diagnosed the root cause, wrote failing tests reproducing the dev-mode 500 before the fix, and applied the gate. I reviewed the full diff before pushing.

🤖 Generated with Claude Code

Legacy explicit-values viewsets often pair a write-oriented
serializer_class with a different read shape, so validating their
serialized output against the serializer raised spurious ValueErrors
(500s) in dev mode. Track whether a class derives its values from its
serializer and only build/apply the DEBUG validation schema when it
does.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added DEV: backend Python, databases, networking, filesystem... SIZE: small and removed DEV: backend Python, databases, networking, filesystem... labels Jun 5, 2026

@marcellamaki marcellamaki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does fix the problem 🙂

@rtibbles rtibbles merged commit ae1692e into learningequality:develop Jun 9, 2026
73 checks passed
@rtibbles rtibbles deleted the gate-debug-validation branch June 9, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants