ShivamSharma43 opened a new issue, #9414:
URL: https://github.com/apache/devlake/issues/9414

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/devlake/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### What happened
   
   The body-based webhook close endpoints added in #8939 (for #8910), `POST 
/plugins/webhook/connections/:connectionId/issue/close` and `POST 
/plugins/webhook/connections/by-name/:connectionName/issue/close`, decode and 
validate `resolutionDate` and `originalStatus` from the request body 
(`CloseIssueByBodyRequest` in `plugins/webhook/api/issues.go`, also in the 
Swagger docs), but never use them. `CloseIssueByBody` and 
`CloseIssueByBodyByName` only copy `issueKey` into the path params and then 
call the shared `closeIssue`, which always does:
   
   ```go
   domainIssue.Status = ticket.DONE
   domainIssue.OriginalStatus = ``
   now := time.Now()
   if domainIssue.ResolutionDate == nil {
        domainIssue.ResolutionDate = &now
   }
   ```
   
   and the same for the incident row.
   
   So a request like the one in the #8939 description
   
   ```json
   {"issueKey": "DLK-1234", "resolutionDate": "2026-06-13T10:00:00Z"}
   ```
   
   stores the time the request reached DevLake as `resolution_date` in `issues` 
and `incidents`, and `lead_time_minutes` is computed from that time. Any delay 
between the incident being resolved and the webhook call (retries, batching, 
sending past recoveries) adds to the incident's lead time, and with it DORA's 
failed deployment recovery time. The `originalStatus` sent in the body is also 
replaced with an empty string.
   
   ### What do you expect to happen
   
   When the body has `resolutionDate`, the issue and its incident get that 
resolution date and their lead time is computed from it. When the body has 
`originalStatus`, it is stored in `original_status`. Without these fields, the 
endpoints behave as now (resolution date set to now if missing, empty original 
status). The path-based close endpoints don't change.
   
   ### How to reproduce
   
   1. Create an incident with `POST /plugins/webhook/connections/1/issues` 
(`"type": "INCIDENT"`, `"status": "IN_PROGRESS"`, `"createdDate": 
"2026-06-13T09:00:00Z"`).
   2. Close it with `POST /plugins/webhook/connections/1/issue/close` and the 
body `{"issueKey": "<key>", "resolutionDate": "2026-06-13T10:00:00Z", 
"originalStatus": "resolved"}`.
   3. In `issues` and `incidents`, `resolution_date` is the current time 
instead of `2026-06-13 10:00:00`, `lead_time_minutes` is not 60, and 
`original_status` is empty.
   
   ### Anything else
   
   Proposed fix (I have a PR ready): pass the body's `resolutionDate` and 
`originalStatus` from the two body-based handlers to `closeIssue`, with unit 
tests for the handler. Since the resolution date can now come from the client, 
the lead time is left unset when it is before the created date, instead of 
wrapping around to a huge `uint`.
   
   ### Version
   
   main
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to