Skip to content

Gate DEBUG output validation to serializer-derived viewsets#14811

Open
rtibbles wants to merge 1 commit into
learningequality:developfrom
rtibbles:gate-debug-validation
Open

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

Conversation

@rtibbles
Copy link
Copy Markdown
Member

@rtibbles rtibbles commented Jun 5, 2026

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
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.

1 participant