Bug: incorrect parent_id in item update webhook

I think I have come across a bug in the webhook payloads.

Scenario:

I have set up a “Page” model to be displayed in a tree-like structure and I have the following pages:

A
- B (nested in A)
C

When I drag and drop the page B to be nested in C, like so:

A
C
- B (nested in C)

A webhook with the correct event_type: 'update' fires, but its payload seems to have incorrect data. The new parent ID under entity.attributes.parent_id seems to have an old value, still being the ID of page A. I would expect the ID to be of the new parent, that is page C.

Reproduction code:

console.log(payload.entity.id, 'has been updated');
console.log('Old parent was', payload.previous_entity.attributes.parent_id);
console.log('New parent is', payload.entity.attributes.parent_id);

Output:

JA8rUQGIRdmdoPrtO1emKg has been updated
Old parent was JF2POm-4SZqwsAAYFqoOQg
New parent is JF2POm-4SZqwsAAYFqoOQg

Please take a look into this, thank you.

Hi @david.ovcacik,

Welcome to the forum and thank you for the report!

Hmm, it looks like if you change the webhook to be on publish instead of update, you should see the correct new parent in the webhook. The update webhook seems to send the current (previous) parent instead of the new one.

I’m not sure if this is a bug, but I’ll report it and double-check for you just in case. I’ll let you know as soon as I hear back.

Thank you for a quick reply, Roger! I found out that moving published pages fires both update and publish webhooks, but draft pages only get the incorrect update webhook, which is unusable.

1 Like

Thank you @david.ovcacik! Good catch. I’ve amended my bug report to let the developers know.

Hi @david.ovcacik,

This was indeed a bug, and it should be fixed now. Both the update and publish webhooks should show the correct new parent now.

Thank you again for the detailed report!

Thanks for such a prompt and straightforward resolution! Hats off to you :wink:

1 Like