Skip to content

Fix FileInfo.fields deserialization when API returns an empty array - #438

Closed
amalsaidov wants to merge 1 commit into
crowdin:masterfrom
amalsaidov:fix/fileinfo-fields-deserialize
Closed

amalsaidov wants to merge 1 commit into
crowdin:masterfrom
amalsaidov:fix/fileinfo-fields-deserialize

Conversation

@amalsaidov

Copy link
Copy Markdown

What

FileInfo.fields is a Map<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 MismatchedInputException while deserializing FileResponseObject (both for File and plain FileInfo responses).

Why / How

Annotated FileInfo.fields with 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 a File payload -> getFields() is null
  • fields: [] on a plain FileInfo payload -> getFields() is null
  • fields: { ... } object -> still deserialized into the map (no regression)

Verified the two empty-array tests fail with MismatchedInputException without the fix and pass with it. Full suite green via ./gradlew test.

Fixes #435

🤖 Generated with Claude Code

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>
@andrii-bodnar

Copy link
Copy Markdown
Member

Thanks for the contribution! I'm closing this, because it duplicates #436

@amalsaidov

Copy link
Copy Markdown
Author

Thanks for taking a look 🙏 Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileInfo.fields fails to deserialize when API returns an empty array

2 participants