Merge Request Approved event Webhook payload contains old updated_at
Summary
Webhook payload data for Merge Request Approved events contain an incorrect updated_at field in the object_attributes. It seems that the updated_at timestamp is updated in the MergeRequest model record after the Webhook is sent.
A customer engaged Support regarding this behaviour. ZenDesk ticket refers (internal). They expect the updated_at timestamp in the Webhook payload to contain the timestamp resulting from the approval action.
Example timings from my testing:
Webhook received: 2023-06-07 05:14:11 UTC
Webhook payload updated_at: 2023-06-07 05:08:09 UTC
Rails Model updated_at: 2023-06-07 05:14:11.244585000 UTC +00:001
Steps to reproduce
- Setup a Webhook for Merge Request events
- Create a new branch
- Create an MR for the new branch
- Wait 60s
- Add a file/change to the source branch. Confirm
updated_atin Webhook payload is the same asupdated_atin theMergeRequestmodel record - Wait 60s
- Add a Reviewer to the MR. Confirm
updated_atin Webhook payload is the same asupdated_atin theMergeRequestmodel record - Wait 60s
- Approve the MR.
updated_atin the Webhook payload is not the same asupdated_atin theMergeRequestmodel record - Wait 60s
- Unapprove the MR. Confirm
updated_atin Webhook payload is the same asupdated_atin theMergeRequestmodel record
Example Project
What is the current bug behavior?
The Webhook for Merge Request Approved action event contains the updated_at timestamp from before the approval. This is not consistent with other actions and their Webhook payloads.
What is the expected correct behavior?
The updated_at for each action should ideally contain the timestamp of the update corresponding to the action
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)