Skip to content
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

"unknown" option should apply to nested fields #629

Closed
zhengxiongzhao opened this issue Aug 10, 2021 · 4 comments
Closed

"unknown" option should apply to nested fields #629

zhengxiongzhao opened this issue Aug 10, 2021 · 4 comments

Comments

@zhengxiongzhao
Copy link

default at parser instantiation does not apply to nested fields, unless the nested schema(s) have the desired ma.EXCLUDE setting .

# No Working
parser = Parse(unknown=ma.EXCLUDE)
parser.parse({
            "book": fields.Nested(
                {
                    'id': fields.Str(),
                    'author': fields.Str(required=True)
                },
            )
        }, request)
}

# Working
parser.parse({
            "book": fields.Nested(
                {
                    'id': fields.Str(),
                    'author': fields.Str(required=True)
                },
                unknown=ma.EXCLUDE
            )
        }, request)
}
@sirosen
Copy link
Collaborator

sirosen commented Aug 11, 2021

I think marshmallow should support propagation of this setting as an opt-in flag, but that's a marshmallow matter, not a webargs one. I can't think of anything appropriate for webargs itself to do to better support this case.

@zhengxiongzhao, I'm confused about what sort of resolution you're looking for from webargs here? Or are you asking for advice about how to work around this limitation?

@sirosen
Copy link
Collaborator

sirosen commented Aug 27, 2021

Absent any possible action for us within webargs, I'm going to close this.

This is surprising for users, and I think it's bad that there's no ready answer other than "yes" or "use a schema factory". But it needs resolution upstream.

@sirosen sirosen closed this as completed Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants