Fix JSON parsing of empty OCS results (#112) - #113
Merged
Conversation
The OCS API serializes an empty PHP associative array as a JSON array
"[]" rather than an object "{}". When a result was empty (e.g. an empty
user or group list), fields typed as objects (GroupListAnswer.Data,
UserDetailsListAnswer.Users, User) received "[]" and Jackson threw a
MismatchedInputException.
Enable DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT on the
shared ObjectMapper so such empty arrays deserialize to null; the answer
classes already treat null as an empty result.
Adds JsonAnswerParserTest, a server-independent unit test covering the
empty-array cases and a populated case as a regression guard.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Fixes the empty-collection JSON deserialization bug (category 1 of #112), a real bug affecting end users, not just tests.
The OCS API serializes an empty PHP associative array as a JSON array
[]rather than an object{}. When a result was empty (e.g. listing users or groups on an empty result), fields typed as objects received[]and Jackson threw:affecting
GroupListAnswer.Data,UserDetailsListAnswer.Users, andUser.Change
DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECTon the sharedObjectMapperinJsonAnswerParser, so an empty[]deserializes tonull. The answer classes already treatnullas an empty result (getAllGroups,getAllUserDetails,getAllUsersreturn empty lists).JsonAnswerParserTest— a server-independent unit test (runs without Docker) covering the empty-array cases plus a populated case as a regression guard. All 4 pass locally.Scope
This addresses category 1 of #112 only. The remaining categories (WebDAV 404s, sharing, and cascading user/group failures) are still tracked in #112. The CI job stays
continue-on-erroruntil the full suite is green.Partially addresses #112.
🤖 Generated with Claude Code