Inconsistent error messages using a nested partial schema.
See original GitHub issueI have these schemas.
class MySchema(Schema):
title = fields.String(required=True)
class Wrapped(Schema):
wrapped = fields.Nested(MySchema(partial=True), required=True)
s = Wrapped()
print(s.load({}))
UnmarshalResult(data={}, errors={'wrapped': {'title': ['Missing data for required field.']}})
Since MySchema
is a nested partial in Wrapped
, required errors related to MySchema
should not appear when I send in an empty dict as data. At least thats what I would except. Rather the error should only say that the required field wrapped
is missing.
I understand this might be a weird example. But it does seem like a subtle bug. Removing required is also not what I want because I want to be able to assume that if the schema is valid, I at least have an output like: {'wrapped': {}}
Using marshmallow 2.11.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Upgrading to Newer Releases — marshmallow 3.19.0 ...
In 3.3, fields.Nested may take a callable that returns a schema instance. Use this to resolve order-of-declaration issues when schemas nest each other....
Read more >Error conditions in Azure Databricks - Microsoft Learn
Fail to insert a value of type into the type column due to an overflow. Use try_cast on the input value to tolerate...
Read more >marshmallow - Read the Docs
To customize the error message for required fields, pass a dict with a required ... Schemas can be nested to represent relationships between...
Read more >Spark SQL, DataFrames and Datasets Guide
The case class defines the schema of the table. The names of the arguments to the case class are read using reflection and...
Read more >XSL Transformations (XSLT) Version 3.0 - W3C
Abstract. This specification defines the syntax and semantics of XSLT 3.0, a language designed primarily for transforming XML documents into ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up creating my own fork that fixes that problem. We use it in my company. Later on I even created my own library similar to Marshmallow and right now we are transitioning to this new library.
You can start with a fork and later put pressure on Marshmallow maintainers to remove that offending feature.
I think it all roots in the same crazy idea to report all required fields for all nested objects regardless of what actual payload looks like. Consider this example: https://github.com/marshmallow-code/marshmallow/issues/319#issuecomment-232221049. I guess implementation for this feature takes precedence to partial.