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.

`fields.Nested` missing in the request returns an empty list `[]`

See original GitHub issue

Hi, I would like to report a weird behavior I’ve stumbled upon. Consider we have the following schemas…

import marshmallow as ma

class OuterSchema(ma.Schema):
    outer_field_one = ma.fields.Str()
    outer_field_two = ma.fields.Str()
    outer_field_three = ma.fields.Nested('InnerSchema', many=True)

class InnerSchema(ma.Schema):
    inner_field_one = ma.fields.Str()
    inner_field_two = ma.fields.Str()

when I try to pass a request containing only the outer_field_one, I tend to get both the outer_field_one and outer_field_three with second one containing an empty list []. I’m expecting that since I didn’t include outer_field_three in the request, it shouldn’t be included.

I tried to see if this behavior might be native to marshmallow itself, and do the de-serializing myself, but apparently it returns the correct results, which contains only the outer_field_one.

Was this behavior intentional?? thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lafrechcommented, Dec 9, 2016

Thank you guys for reporting/fixing this. Just got hit by this and latest release works a treat.

1reaction
sloriacommented, Nov 28, 2016

Thanks guys–I’ve released 1.5.1 with the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Return empty JSON object with Flask-Restful Nested field ...
This can be achieved by creating a custom field, like this: class NestedWithEmpty(Nested): """ Allows returning an empty dictionary if marshaled value is ......
Read more >
Relation queries (Concepts) - Prisma
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
Read more >
Specify nested and repeated columns in table schemas
For Source, in the Create table from field, select Empty table. In the Destination section, specify the following fields: For Dataset, select the...
Read more >
Querying arrays with complex types and nested structures
Your source data often contains arrays with complex data types and nested structures. Examples in this section show how to change element's data...
Read more >
Response marshalling - Flask-RESTPlus - Read the Docs
If for some reason your data object doesn't have an attribute in your fields list, you can specify a default value to return...
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