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

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>
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

This branch has not been deployed

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

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