fix: users.presence ignoring comma-separated IDs after OpenAPI migration

Merged
RI
5mo ago
+50-1

Proposed changes

Regression in 8.4.0: GET /v1/users.presence?ids=id1,id2,id3 returns an empty array when called with multiple comma-separated IDs. Single ID works fine. This breaks user presence on mobile, where everyone appears offline.

Root cause: PR #39553 (OpenAPI migration) added ajvQuery validation with anyOf: [string, array]. Combined with ajvQuery's coerceTypes: 'array', AJV coerces "id1,id2" into ["id1,id2"] (single-element array), skipping the .split(',') logic.

The endpoint accepts three formats:

  • ?ids=userId1 - single ID (string)
  • ?ids=userId1&ids=userId2 - repeated params (array)
  • ?ids=userId1,userId2 - comma-separated (string, but AJV coerces to ["userId1,userId2"] β€” broken case)

Fix:

  • Replaced anyOf with type: ['string', 'array'] to avoid AJV coercion issues (ajv#1140)

Issue(s)

Steps to test or reproduce

  1. GET /v1/users.presence?ids=<userId> - single ID, returns the user
  2. GET /v1/users.presence?ids=<userId1>,<userId2> - comma-separated, returns empty (before fix), returns both (after fix)
  3. GET /v1/users.presence?ids=<userId1>&ids=<userId2> - repeated params, returns both

Summary by CodeRabbit

  • Bug Fixes
    • Fixed the users.presence endpoint to correctly handle multiple comma-separated user IDs instead of returning an empty array.

Review Change Stack