Repository navigation
fix: Handle dynamic types and JSON containers in SerializationManager.deserialize - #4874
Closed
ThangVuNguyenViet wants to merge 1 commit into
Closed
ThangVuNguyenViet wants to merge 1 commit into
ThangVuNguyenViet wants to merge 1 commit into
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
ThangVuNguyenViet
marked this pull request as draft
March 21, 2026 22:06
ThangVuNguyenViet
force-pushed
the
fix/dynamic-map-deserialization
branch
from
March 21, 2026 22:10
3c5994b to
915934f
Compare
ThangVuNguyenViet
marked this pull request as ready for review
March 25, 2026 12:53
….deserialize When deserializing a Map<String, dynamic> field, the generated fromJson code calls deserialize<dynamic>(value) for each entry. If a value is a nested List or Map, the previous code had no matching branch and threw DeserializationTypeNotFoundException. This fix adds three missing code paths: - When t == dynamic: dispatch on the actual runtime type - When data is List: return as-is (already decoded) - When data is Map: return as-is (already decoded) Fixes reported in discussions serverpod#2722, serverpod#1048, serverpod#444, serverpod#2600
ThangVuNguyenViet
force-pushed
the
fix/dynamic-map-deserialization
branch
from
March 25, 2026 12:56
915934f to
1200434
Compare
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
Collaborator
|
Hi @ThangVuNguyenViet! We appreciate your contribution, but I'll ask you to first open an issue so we can properly evaluate the use case and discuss the rightful approach. This PR cites several discussions, but is not in accordance with the answers from maintainers on them (namely this and this). I'll close this PR for now, but feel free to review the answers on the discussions and open the issue with your use case. |
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.
Fixes deserialization of
Map<String, dynamic>fields where values are nestedListorMapobjects.When Serverpod deserializes a model with a
Map<String, dynamic>field, the generatedfromJsoncode callsdeserialize<dynamic>(value)for each entry. If a value is itself aListorMap(very common in JSON), the previous code had no matching branch and threwDeserializationTypeNotFoundException.This PR adds a missing
t == dynamiccode path toSerializationManager.deserialize:data == null: returns nulldata is Listordata is Map: returns the already-decoded container as-is (only whent == dynamic, so typed deserialization likedeserialize<UserInfo>still delegates to Protocol subclasses)int,String,double)Fixes #2722, #1048, #444, #2600
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 — this adds new handling for previously-unsupported cases that previously threw an exception.