Repository navigation
Fix FileInfo.fields deserialization when API returns an empty array - #438
Closed
amalsaidov wants to merge 1 commit into
Closed
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
The Enterprise API returns an empty array (`"fields": []`) instead of an object when a file has no custom fields. Since `FileInfo.fields` is a `Map<String, Object>`, Jackson throws a `MismatchedInputException` when deserializing `FileResponseObject`. Annotate the field with the existing `EmptyArrayToNullDeserializer`, the same convention already used across the codebase (e.g. `Webhook.headers`), so an empty array is treated as an absent value while object payloads keep deserializing as before. Fixes crowdin#435 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
|
Thanks for the contribution! I'm closing this, because it duplicates #436 |
Author
|
Thanks for taking a look 🙏 Appreciate it. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
FileInfo.fieldsis aMap<String, Object>, but the Enterprise API returns an empty array instead of an object when a file has no custom fields:"fields": []This makes Jackson throw a
MismatchedInputExceptionwhile deserializingFileResponseObject(both forFileand plainFileInforesponses).Why / How
Annotated
FileInfo.fieldswith the existing@JsonDeserialize(using = EmptyArrayToNullDeserializer.class). This is the same convention already used across the codebase for fields the API may return as an empty array (e.g.Webhook.headers,ProjectSettings,User). An empty array is treated as an absent value (null), while object payloads keep deserializing exactly as before.How tested
Added three cases to
FileOptionsDeserializationTest:fields: []on aFilepayload ->getFields()isnullfields: []on a plainFileInfopayload ->getFields()isnullfields: { ... }object -> still deserialized into the map (no regression)Verified the two empty-array tests fail with
MismatchedInputExceptionwithout the fix and pass with it. Full suite green via./gradlew test.Fixes #435
🤖 Generated with Claude Code