Skip to content

fix(events): serialize nested entities in webhook payloads - #8382

Open
chiliec wants to merge 1 commit into
nextcloud:mainfrom
chiliec:fix/webhook-serialize-nested-entities
Open

fix(events): serialize nested entities in webhook payloads#8382
chiliec wants to merge 1 commit into
nextcloud:mainfrom
chiliec:fix/webhook-serialize-nested-entities

Conversation

@chiliec

@chiliec chiliec commented Sep 13, 2026

Copy link
Copy Markdown

Summary

Webhook event filters like {"event.card.labels.title": "foo"} crash in webhook_listeners with:

PHPMongoQuery::_executeOperatorOnElement(): Argument #4 ($document) must be of type array, OCA\Deck\Db\Label given

ACardEvent::getWebhookSerializable() returned $this->card->jsonSerialize(), which is only one level deep: labels, assignedUsers, attachments etc. stay as Label/Assignment objects inside the array. json_encode would resolve them later, but PHPMongoQuery runs the filter on the raw array before encoding and can only traverse arrays.

Fix: serialize the card / acl through json_encode+json_decode so the payload handed to the webhook listener is plain nested arrays. Same change on AAclEvent for consistency (its participant relation has the same shape).

Validation

Reproduced against a local nextcloud/server master checkout with webhook_listeners' own PHPMongoQuery:

  • before: executeQuery(['event.card.labels.title' => 'foo'], $data) → the exact TypeError from the issue
  • after: returns true for a matching label title, false for a non-matching one

Regression test testCardEventSerializesNestedEntitiesAsArrays added to the existing WebhookCompatibleEventsTest; it fails on main (Failed asserting that OCA\Deck\Db\Label Object ... is of type array) and passes with this change.

  • composer run test:unit — 425 tests, 4088 assertions, OK (the single SUBJECT_LABEL_DELETE warning is pre-existing on main)
  • composer run cs:check — clean
  • composer run psalm — no errors

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Documentation (manuals or wiki) has been updated or is not required

Webhook filters on nested relations (e.g. event.card.labels.title) failed
because getWebhookSerializable() returned Label/Assignment objects inside
the card array, which PHPMongoQuery cannot traverse. Serialize the card
and acl through json_encode/json_decode so the payload is plain arrays.

Resolves: nextcloud#8245
Signed-off-by: Vladimir Babin <vovababin@gmail.com>
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.

[bug] Webhook events do not serialize labels in mongo filters

1 participant