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

Are nested options applied correctly? #2180

Open
matuqam opened this issue Sep 1, 2023 · 1 comment
Open

Are nested options applied correctly? #2180

matuqam opened this issue Sep 1, 2023 · 1 comment

Comments

@matuqam
Copy link

matuqam commented Sep 1, 2023

Experimenting with only, I noticed it is possible to assign an invalid value to a Field's only attribute.

Looking at the code in the __apply_nested_option method of the schema.Schema class, there is no validation done when propagating the only value to a field.

from marshmallow import fields, Schema

class S(Schema):
    f = fields.Str()

S(only=['f.a.b'])
<S(many=False)>  # actual output.
ValueError: Option: 'only' with value: 'a.b' is not valid for Field: 'f'.  # expected output.

All comments are welcome.

@lafrech
Copy link
Member

lafrech commented Sep 10, 2023

I wouldn't say it is a bug, but we already try to validate inputs to catch typos and we could add a check for this as well.

Contribution welcome if someone is willing to investigate.

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

2 participants