Skip to content

Add a compatibility setting for ListSerializer error formats - #10027

Merged
auvipy merged 4 commits into
encode:mainfrom
Kub-AT:listserializer-error-format-compatibility
Sep 3, 2026
Merged

Add a compatibility setting for ListSerializer error formats#10027
auvipy merged 4 commits into
encode:mainfrom
Kub-AT:listserializer-error-format-compatibility

Conversation

@Kub-AT

@Kub-AT Kub-AT commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #9837 and #10018.

This adds LIST_SERIALIZER_ERRORS_AS_DICT. It defaults to True, preserving the dictionary format introduced in 3.18.0.

Projects can set it to False to temporarily restore the old list-based format while migrating. This emits RemovedInDRF320Warning, and the list format will be removed in 3.20.

Comment thread rest_framework/serializers.py
@auvipy
auvipy requested a lite review from Copilot August 30, 2026 16:57
@auvipy
auvipy self-requested a review August 30, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a REST framework setting to control the ListSerializer (many=True) per-item validation error format, restoring the legacy list-based structure as the default while allowing opt-in to the newer dict-based format.

Changes:

  • Introduces REST_FRAMEWORK['LIST_SERIALIZER_ERRORS_AS_DICT'] (default False) and updates ListSerializer.to_internal_value() to emit legacy list-form errors (with a deprecation warning) unless the dict format is enabled.
  • Updates and expands serializer list-related tests to cover both formats and warning behavior.
  • Documents the new setting and the deprecation/transition plan in the settings and serializers guides.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_serializer.py Adjusts a regression test to expect the new deprecation warning alongside the raised validation error.
tests/test_serializer_lists.py Adds coverage for default legacy list errors, opt-in dict errors, and explicit legacy setting behavior.
tests/test_serializer_bulk_update.py Updates expected bulk many=True error shapes to match the restored legacy list format and asserts warnings.
rest_framework/settings.py Adds the new LIST_SERIALIZER_ERRORS_AS_DICT default setting.
rest_framework/serializers.py Implements conditional legacy-vs-dict error formatting and emits a deprecation warning for the legacy default.
rest_framework/init.py Adds RemovedInDRF320Warning warning class used for the deprecation signal.
docs/api-guide/settings.md Documents the new LIST_SERIALIZER_ERRORS_AS_DICT setting and its behavior.
docs/api-guide/serializers.md Updates serializer error-format documentation to note deprecation and explain enabling dict-based errors.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rest_framework/serializers.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread rest_framework/__init__.py Outdated
Comment thread rest_framework/settings.py Outdated
@auvipy
auvipy merged commit 5668281 into encode:main Sep 3, 2026
7 checks passed
@browniebroke

Copy link
Copy Markdown
Collaborator

Should we do a 3.18.1 release for this? I think it blocks a few people from upgrading... You can start here @auvipy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants