question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent error messages using a nested partial schema.

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
maximkulkincommented, Jan 17, 2017

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.

1reaction
maximkulkincommented, Jan 17, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found