You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Errors from parent-level validation of nested serializer fields break the browsable API. #4073
Create a serialiser that contains a nested serialiser as one of its fields.
Add validation for the nested serialiser field in the top-level serialiser (for example, as a validate_<field name> method.
Instantiate the serialiser with data that will cause the validate_<field name> method to fail.
Retrieve the NestedBoundField for the nested serialiser using the serialiser's form-like api (<serializer instance>[<field name>])
Attempt to retrieve a BoundField for one of the nested serialiser's fields from the NestedBoundField instance.
Expected behaviour
A BoundField is returned.
Actual behaviour
An AttributeError is raised, as the NestedBoundField attempts to treat its errors as a dictionary, even though they are the list of error messages from the parent serialiser's validation error. This impacts the browsable API.
(It's not entirely clear to me what the behaviour should be where a nested serialiser has a list of errors rather than a dictionary, but it probably shouldn't be to error out.)
Reacted by Alexander, Ken Bolton and Gustavo Lino Fernandes
changed the title [-]Errors from parent-level validation of nested serializer fields breaks the form-like API[/-][+]Errors from parent-level validation of nested serializer fields break the browsable API.[/+]on Jun 1, 2016
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi @auvipy,
I’ve been looking into this issue and noticed that NestedBoundField.__getitem__() receives self.errors as a list when parent-level validation fails. This causes child fields to have errors=None, which breaks the browsable API.
As a minimal fix, I’m considering normalizing list-type errors to an empty dict:
ifisinstance(self.errors, list):
error= {}
Before working on this, is this the correct direction for the fix?
Thanks!
Activity
Add failing test for issue encode#4073
lovelydinosaur commentedon Jun 1, 2016
Confirmed - thanks for raising the issue.
Using the following...
Submitting the form results in...
[-]Errors from parent-level validation of nested serializer fields breaks the form-like API[/-][+]Errors from parent-level validation of nested serializer fields break the browsable API.[/+]58 remaining items
carltongibson commentedon Oct 5, 2017
I'm going to de-milestone this for now.
stale commentedon Oct 19, 2025
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Shrikantgiri25 commentedon Nov 28, 2025
Hi @auvipy,
I’ve been looking into this issue and noticed that
NestedBoundField.__getitem__()receivesself.errorsas a list when parent-level validation fails. This causes child fields to haveerrors=None, which breaks the browsable API.As a minimal fix, I’m considering normalizing list-type errors to an empty dict:
Before working on this, is this the correct direction for the fix?
Thanks!
Prevent NestedBoundField child access crash after parent validation e…
browniebroke commentedon Feb 24, 2026
Just tested again that example and it works now: