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

be more verbose: marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']} #1975

Open
milahu opened this issue Apr 17, 2022 · 1 comment

Comments

@milahu
Copy link

milahu commented Apr 17, 2022

im debugging an app that throws

marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']}

the problem is that marshmallow.Schema._deserialize is called like

data = OrderedDict() # is_collection(data) == False
self._deserialize(data, many = True)

to fix this, i need either data = [ OrderedDict() ] or many = False

it would be nice if the error message Invalid input type would be more helpful here

for example

# marshmallow/schema.py

        if many:
            if not is_collection(data):
                error_store.store_error([self.error_messages["type"]], index=index, detail="many but no collection")
                ret_l = []  # type: typing.List[_T]

        if not isinstance(data, Mapping):
            error_store.store_error([self.error_messages["type"]], index=index, detail="data is no Mapping")
@mmulqueen
Copy link

This would be incredibly helpful.

Would the project be open to a pull request that splits this into messages that include the expected type, but respects any custom error messages already defined?

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