Repository navigation
fix: Generate deserializers for container types of exception and sealed parent fields - #5946
Merged
marcelomendoncasoares merged 3 commits intoNov 5, 2026
Conversation
Contributor
Author
|
The failing job looks unrelated to this change. |
marcelomendoncasoares
approved these changes
Nov 5, 2026
marcelomendoncasoares
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for fixing this one, @BiAksoy! 🚀
marcelomendoncasoares
merged commit Nov 5, 2026
9e02d16
into
serverpod:main
959 of 960 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a container field such as
List<FieldProblem>is declared on a serializable exception, or on the sealed parent of a hierarchy, and no other class declares a field of the same type, the generatedProtocol.deserializehas no branch for it. Decoding the object fails withNo deserialization found for type List<FieldProblem>.The field types that get a branch are collected from
unsealedModels.whereType<ModelClassDefinition>():serverpod/tools/serverpod_cli/lib/src/generator/dart/library_generators/library_generator.dart
Lines 279 to 283 in 0bd8e09
The type filter leaves out exceptions, and
unsealedModelsleaves out every sealed class, whose ownfieldsare the only place the parent's fields are listed.This PR collects the fields from
allModels.whereType<ClassDefinition>()instead.ClassDefinitionis sealed, withModelClassDefinitionandExceptionClassDefinitionas its only subclasses, andallModelsis the listunsealedModelsis filtered from, so the change adds exactly the fields of exceptions and of sealed classes. Enums are notClassDefinitions and are unaffected. Fields are still filtered byshouldIncludeFieldand deduplicated as before. The class branches still come fromunsealedModels, so sealed classes get no branch of their own, as before.With the steps from #5945:
Before:
After:
The commits are split into the fix with its generator tests, the test server models and test, and the regenerated code.
Tests:
Listbranches are generated for aListfield of a model declared on an exception (protocol_test.dart), on a sealed parent model (inheritance_protocol_test.dart) and on a sealed parent exception (inheritance_exception_protocol_test.dart). All of them fail onmain. With the type filter changed butunsealedModelskept, the exception tests pass and the four sealed ones still fail.ExceptionWithModelList, with aList<ExceptionDetail>field, and a sealedSealedListParentwith aList<SealedListItem>field and a child,SealedListChild. Neither list type is used elsewhere.model_list_field_deserialization_test.dartdecodes both with the server protocol and, by class name, with the client protocol. With the test server generated frommain's generator, the four tests fail with the error above.util/generate_allwith the change regenerates every other package identically. In the test server and client protocols, the only change besides the new models is that the existingList<String>branch moves up, becauseExceptionWithData.errorFieldsnow also contributes it.serverpod_clisuite and the test server's unit tests pass locally, anddart analyze --fatal-infosis clean for the CLI, the test server and the test client.Fixes #5945.
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
None.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.