fix(events): serialize nested entities in webhook payloads - #8382
Open
chiliec wants to merge 1 commit into
Open
Conversation
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>
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.
labelsin mongo filters #8245Summary
Webhook event filters like
{"event.card.labels.title": "foo"}crash inwebhook_listenerswith:ACardEvent::getWebhookSerializable()returned$this->card->jsonSerialize(), which is only one level deep:labels,assignedUsers,attachmentsetc. stay asLabel/Assignmentobjects inside the array.json_encodewould resolve them later, butPHPMongoQueryruns the filter on the raw array before encoding and can only traverse arrays.Fix: serialize the card / acl through
json_encode+json_decodeso the payload handed to the webhook listener is plain nested arrays. Same change onAAclEventfor consistency (itsparticipantrelation has the same shape).Validation
Reproduced against a local
nextcloud/servermaster checkout withwebhook_listeners' ownPHPMongoQuery:executeQuery(['event.card.labels.title' => 'foo'], $data)→ the exactTypeErrorfrom the issuetruefor a matching label title,falsefor a non-matching oneRegression test
testCardEventSerializesNestedEntitiesAsArraysadded to the existingWebhookCompatibleEventsTest; it fails onmain(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 singleSUBJECT_LABEL_DELETEwarning is pre-existing on main)composer run cs:check— cleancomposer run psalm— no errorsChecklist