Expose content_version for optimistic locking on issue and PR edits (#37035)

- Add `content_version` field to Issue and PullRequest API responses
- Accept optional `content_version` in `PATCH
/repos/{owner}/{repo}/issues/{index}` and `PATCH
/repos/{owner}/{repo}/pulls/{index}` — returns 409 Conflict when stale,
succeeds silently when omitted (backward compatible)
- Pre-check `content_version` before any mutations to prevent partial
writes (e.g. title updated but body rejected)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Myers Carpenter
2026-03-30 09:44:32 -04:00
committed by GitHub
parent 2633f9677d
commit c31e0cfc1c
8 changed files with 135 additions and 25 deletions

View File

@@ -10362,6 +10362,7 @@
}
},
"patch": {
"description": "Pass `content_version` to enable optimistic locking on body edits.\nIf the version doesn't match the current value, the request fails with 409 Conflict.\n",
"consumes": [
"application/json"
],
@@ -24766,6 +24767,11 @@
"type": "string",
"x-go-name": "Body"
},
"content_version": {
"type": "integer",
"format": "int64",
"x-go-name": "ContentVersion"
},
"due_date": {
"type": "string",
"format": "date-time",
@@ -24938,6 +24944,11 @@
"type": "string",
"x-go-name": "Body"
},
"content_version": {
"type": "integer",
"format": "int64",
"x-go-name": "ContentVersion"
},
"due_date": {
"type": "string",
"format": "date-time",
@@ -26223,6 +26234,11 @@
"format": "int64",
"x-go-name": "Comments"
},
"content_version": {
"type": "integer",
"format": "int64",
"x-go-name": "ContentVersion"
},
"created_at": {
"type": "string",
"format": "date-time",
@@ -27725,6 +27741,11 @@
"format": "int64",
"x-go-name": "Comments"
},
"content_version": {
"type": "integer",
"format": "int64",
"x-go-name": "ContentVersion"
},
"created_at": {
"type": "string",
"format": "date-time",