marshmallow-code / marshmallow-code/marshmallow

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

Open
#1,975 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

im debugging an app that throws

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

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

```py
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

```py
# 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")
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in marshmallow/schema.py at Schema._deserialize and inspect the existing many and Mapping validation branches. Make the Invalid input type errors distinguish a non-collection passed with many=True from data that is not a Mapping, then verify that both cases report the relevant context.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.