Skip to content

Fix JSON parsing of empty OCS results (#112) - #113

Merged
a-schild merged 1 commit into
mainfrom
fix/112-empty-collection-json
Jul 24, 2026
Merged

Fix JSON parsing of empty OCS results (#112)#113
a-schild merged 1 commit into
mainfrom
fix/112-empty-collection-json

Conversation

@a-schild

Copy link
Copy Markdown
Owner

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:

MismatchedInputException: Cannot deserialize value of type ... from Array value (START_ARRAY)

affecting GroupListAnswer.Data, UserDetailsListAnswer.Users, and User.

Change

  • Enable DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT on the shared ObjectMapper in JsonAnswerParser, so an empty [] deserializes to null. The answer classes already treat null as an empty result (getAllGroups, getAllUserDetails, getAllUsers return empty lists).
  • Add 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-error until the full suite is green.

Partially addresses #112.

🤖 Generated with Claude Code

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>
@a-schild
a-schild merged commit 944616c into main Jul 24, 2026
1 check passed
@a-schild
a-schild deleted the fix/112-empty-collection-json branch July 24, 2026 09:19
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.

1 participant