Skip to content

fix(webhook): use resolutionDate and originalStatus when closing by body - #9415

Merged
klesh merged 1 commit into
apache:mainfrom
ShivamSharma43:fix/webhook-close-by-body-fields
Nov 19, 2026
Merged

klesh merged 1 commit into
apache:mainfrom
ShivamSharma43:fix/webhook-close-by-body-fields

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Summary

The body-based webhook close endpoints ignored the resolutionDate and originalStatus sent in the request body.

CloseIssueByBody and CloseIssueByBodyByName (added in #8939) decode and validate CloseIssueByBodyRequest, which has issueKey, resolutionDate and originalStatus, but only copied issueKey into the path params before calling the shared closeIssue. closeIssue always cleared original_status and set resolution_date to the current time when it was missing, for the issue and for its incident. So an incident closed with {"issueKey": "DLK-1234", "resolutionDate": "2026-06-13T10:00:00Z"} got the time the webhook arrived as its resolution date, and its lead time (and DORA's failed deployment recovery time) was computed from that. Details in #9414.

Changes:

  • api/issues.go: closeIssue takes the optional resolution date and original status. The two body-based handlers pass the request's values; the path-based handlers pass nil and "", so they behave as before. A given resolutionDate replaces the stored one; without it, a missing resolution date is still set to now. A given originalStatus is stored; without it, original_status is still cleared. The same applies to the incident row.
  • api/issues.go: since the resolution date can now come from the client, the lead time is only computed when the resolution date is not before the created date. Before, a negative duration would wrap around to a huge uint.
  • api/issues_test.go (new): calls the handlers against a mocked DAL with an open incident created at 09:00.
    • TestCloseIssueByBodyUsesResolutionDateAndOriginalStatus closes it by body with resolutionDate 10:00 and originalStatus resolved, and checks the issue and incident get that date, that status and a 60 minute lead time. It fails without the fix (resolution date is now, original status is empty, lead time is about 229,000 minutes).
    • TestCloseIssueWithoutResolutionDateUsesNow checks the path-based CloseIssue still sets the resolution date to now and clears the original status.
    • TestCloseIssueByBodyWithResolutionDateBeforeCreatedDate checks a resolution date before the created date leaves the lead time unset.

The request and response shapes don't change, so the Swagger docs don't need regenerating.

Does this close any open issues?

Fixes #9414

Screenshots

N/A

Other Information

  • go test ./plugins/webhook/... (after make mock): pass.
  • go vet ./plugins/webhook/... and gofmt: clean.
  • No open PR or issue touches the webhook close endpoints.
  • Suggested label: pr-type/bug-fix.
  • AI assistance disclosure: this change was prepared with the help of Claude Code (Claude Opus 5.5), and I reviewed the diff. The commit carries a Generated-by: trailer per the ASF generative tooling guidance.

🤖 Generated with Claude Code

The body-based close endpoints decoded resolutionDate and originalStatus
from the request body but only passed issueKey on to closeIssue, which
always set the resolution date to now (when missing) and cleared the
original status. Incidents closed after a delay got a resolution date
and lead time based on when the webhook arrived.

Pass both values to closeIssue: a given resolutionDate replaces the
stored one, and a given originalStatus is stored. Without them, and for
the path-based endpoints, nothing changes. Leave the lead time unset
when the resolution date is before the created date instead of letting
the negative duration wrap around.

Fixes apache#9414

Generated-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@klesh klesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for your contribution.

@klesh
klesh merged commit 652d7da into apache:main Nov 19, 2026
10 checks passed
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] Body-based close endpoints ignore resolutionDate and originalStatus

3 participants