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.

Allow `ListSerializer` to parse partial good results and ignore bad ones

See original GitHub issue

What is your use-case and why do you need this feature? I’m receiving a list of items from the server. Some of the items might miss some required fields or be otherwise malformed. In this case, I would like to ignore the items that failed to parse but still parse the ones that I can. Unfortunately, it looks like ListSerializer is failing as soon as it encounters a single list item which it fails to parse.

Describe the solution you’d like Some sort of ignoreFailedListItems or allowPartialListResults configuration.

*This probably applies to all collections.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pdvriezecommented, Oct 30, 2021

A serializer for a type with generic parameter will need a constructor that takes a serializer for that generic parameter. In this case you want to use @SerializeWith(KindListSerializer::class), you don’t need to create a subclass for the parameter type (that will actually not work as you found).

1reaction
sandwwraithcommented, Oct 27, 2021

It looks like the error is imprecise. If your CustomDataSerializer is a serializer for List, it should be applied to the List, not to its generic type arg: val data: @Serializable(CustomDataSerializer::class) List<Data>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serializers - Django REST framework
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily ...
Read more >
unable to update existing data using Django Rest Framework?
BytesIO(json_data) data = JSONParser().parse(stream) serializer = CustomersSerializer(data=data) if serializer.is_valid(): temp_dict = ...
Read more >
3.0 Announcement - Django REST framework
Printable representations on serializers that allow you to inspect exactly what fields are present on the instance. Simple model serializers that are vastly ......
Read more >
tf.distribute.MultiWorkerMirroredStrategy | TensorFlow v2.11.0
If you are interested in last partial batch handling, read this section. ... one input file per worker, we suggest that you disable...
Read more >
drf-yasg Documentation - Read the Docs
ing the specified UI renderer; one of swagger, redoc ... Enable/disable Django login as an authentication/authorization mechanism.
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