-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compat.dump
raises ValidationError when nullable Nested fields (with required subfields) without dump_only of a ResponseSchema are None
#305
Labels
bug
Something isn't working
Comments
fcr--
changed the title
Feb 28, 2024
compat.dump
raises ValidationError when nullable Nested fields (with required subfields) without dump_only are Nonecompat.dump
raises ValidationError when nullable Nested fields (with required subfields) without dump_only of a ResponseSchema are None
This is how to reproduce the bug: from flask_rebar import compat, ResponseSchema
from marshmallow import Schema, fields
class N(Schema):
n = fields.Integer(required=True)
class S(ResponseSchema):
sub = fields.Nested(N(), required=False, allow_none=True)
obj = {"sub": None}
print("default dump:", S().dump(obj))
print("compat.dump:", compat.dump(S(), obj)) which when run:
|
So, this is where the empty dict came from: flask-rebar/flask_rebar/validation.py Lines 46 to 61 in 748b8a5
Which then reaches compat.dump's schema.load(filtered.loadable), resulting on the error shown here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We found this issue when observed a ValidationError being thrown when serializing the response of an endpoint. The curiosity of this issue is that it happens in the
compat.dump
when all of these are true:Then by reading the compat.dump code and the called functions, we've seen that setting
dump_only=True
on the Nested field served as a workaround.More info:
This bug happens at least on version 3.2.0
The text was updated successfully, but these errors were encountered: