Repository navigation
Closed
Labels
Description
Describe the bug
Patch request doesn't follow the conditional header If-Match: <ETag>. It still updates the resource even when the ETag is outdated.
gh --version:
gh version 2.18.1 (2022-10-22 Debian 2.18.1+dfsg1-1)
https://github.com/cli/cli/releases/tag/v2.18.1
Steps to reproduce the behavior
gh api \
-H 'If-Match: <outdated etag>' \
--method PATCH \
https://api.github.com/repos/OWNER/REPO/pulls/PR_NUMBER \
-f body="New PR description"Expected vs actual behavior
Expected: Returns gh: HTTP 412 and the PR body is not updated, because the If-Match precondition isn't satisfied.
Actual behavior: Returned gh: HTTP 412 but the PR body still got updated to New PR description.
Logs
# Get the original PR body
curl -v https://api.github.com/repos/<owner>/<repo>/pulls/4
# Response
< HTTP/2 200
< server: GitHub.com
< date: Tue, 14 Mar 2023 20:15:19 GMT
< content-type: application/json; charset=utf-8
< cache-control: public, max-age=60, s-maxage=60
< vary: Accept, Accept-Encoding, Accept, X-Requested-With
< etag: W/"0c8f2fe064ab2ed5be616b585ba6c11410e5893edeee490739b14de8214350da"
< last-modified: Tue, 14 Mar 2023 20:15:09 GMT
< x-github-media-type: github.v3; format=json
< x-github-api-version-selected: 2022-11-28
...
{
...
"body": "Previous PR description",
"created_at": "2023-01-05T20:23:47Z",
"updated_at": "2023-03-14T20:15:09Z",
...
}
# Try to update the PR body with an invalid (outdated) ETag
gh api \
-H 'If-Match: W/"0000000064ab2ed5be616b585ba6c11410e5893edeee490739b14de8214350da"' \
--method PATCH \
https://api.github.com/repos/pzread/iree/pulls/4 \
-f body="New PR description"
# Output
gh: HTTP 412
# Check the PR body now
curl -v https://api.github.com/repos/<owner>/<repo>/pulls/4
{
..
"body": "New PR description",
"created_at": "2023-01-05T20:23:47Z",
"updated_at": "2023-03-14T20:18:49Z",
...
}
Activity
samcoe commentedon Mar 14, 2023
@pzread I am not familiar with the
If-Matchheader, but this seems like a platform issue that is not specific togh. Are you seeing the same behavior using curl if you provide an invalid ETag?pzread commentedon Mar 14, 2023
Yes, the same thing also happened with
curl. Is there a better place I can post this issue?samcoe commentedon Mar 14, 2023
@pzread I would suggest posting in the discussions here to get the attention of the correct team! Going to close this out for now, please let us know if there turns out to be something that needs to be addressed inside of
gh.