Skip to content

Commit 8a730bf

Browse files
committed
api-request: request a specific GitHub REST API version
We just got surprised with a failure due to an update in the API version: When triggering workflows, the `return_run_details` flag, which used to be required, now triggers an error. Let's avoid getting such nasty surprises by specifying which API version we target. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent bf5b8e5 commit 8a730bf

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎GitGitGadget/github-api-request-as-app.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const gitHubAPIRequestAsApp = async (context, requestMethod, requestPath, body)
3838
body,
3939
{
4040
Authorization: `Bearer ${token}`,
41+
'X-GitHub-Api-Version': '2026-03-10',
4142
}
4243
)
4344
}
4445

4546
module.exports = {
4647
gitHubAPIRequestAsApp
47-
}
48+
}

‎GitGitGadget/github-api-request.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
const gitHubAPIRequest = async (context, token, method, requestPath, payload) => {
22
const { httpsRequest } = require('./https-request')
3-
const headers = token ? { Authorization: `Bearer ${token}` } : null
3+
const headers = {
4+
'X-GitHub-Api-Version': '2026-03-10',
5+
...(token ? { Authorization: `Bearer ${token}` } : {}),
6+
}
47
const answer = await httpsRequest(context, null, method, requestPath, payload, headers)
58
if (answer.error) throw answer.error
69
return answer
710
}
811

912
module.exports = {
1013
gitHubAPIRequest
11-
}
14+
}

0 commit comments

Comments
 (0)