REST API: POST /pulls/{requestId}/request-for-changes approves the pull request instead of requesting changes
#3122
-
State changed as build OD-8447 (16.6.4) is successful
-
OneDev
changed state to 'Closed' 2 days ago
Previous Value Current Value Open
Closed
| Type |
Bug
|
| Priority |
Normal
|
| Assignee | |
| Affected Versions |
16.2.1-16.6.3
|
| Labels |
No labels
|
Issue Votes (0)
Summary
POST /~api/pulls/{requestId}/request-for-changessets the caller's review toAPPROVEDrather thanREQUESTED_FOR_CHANGES. It is functionally identical toPOST /~api/pulls/{requestId}/approve.Root cause
In
server-core/src/main/java/io/onedev/server/rest/resource/PullRequestResource.java,requestForChanges()passestruefor theapprovedparameter:PullRequestReviewService.review(User, PullRequest, boolean approved, String note)branches on that third argument, so the review is stored asAPPROVEDand aPullRequestApproveDatachange is recorded.This appears to be a copy-paste error confined to the REST layer. Every other caller of
review()passes the correct value:web/page/project/pullrequests/detail/PullRequestDetailPage.javatrue(line 2123)false(line 2166)ai/TodResource.javatrue(line 1466)false(line 1484)rest/resource/PullRequestResource.javatrue(line 392)true(line 408)Affected versions
Present since the endpoint was introduced in v16.2.1, and still present in v16.6.3 and on
main. Verified by inspecting the tagged sources for v16.2.0 (endpoint absent), v16.2.1, v16.2.2, v16.2.3, v16.3.0, v16.4.0, v16.4.2, v16.5.0, v16.5.12, v16.6.0 through v16.6.3, andmain.Reproduced against a self-hosted v16.5.12 instance.
Steps to reproduce
Expected: the reviewer's
statusisREQUESTED_FOR_CHANGES. Actual: the reviewer'sstatusisAPPROVED, and the pull request activity records an approval.Requesting changes through the web UI on the same pull request behaves correctly, which confirms the defect is specific to the REST endpoint.