From bc874cdd1d3646020db1dcb5b1f8d566931debfa Mon Sep 17 00:00:00 2001 From: Mike McNeil Date: Sat, 14 Jan 2023 17:25:37 -0600 Subject: [PATCH] GH automation: Add missing user-agent header for GitHub api (#9338) Fixes https://github.com/fleetdm/fleet/pull/9336 --- website/api/controllers/webhooks/receive-from-github.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/api/controllers/webhooks/receive-from-github.js b/website/api/controllers/webhooks/receive-from-github.js index f84e229d18..cb60a512e1 100644 --- a/website/api/controllers/webhooks/receive-from-github.js +++ b/website/api/controllers/webhooks/receive-from-github.js @@ -197,6 +197,10 @@ module.exports = { let repo = repository.name; let issueNumber = issueOrPr.number; let newBotComment; + let baseHeadersForGithubApiRequests = { + 'User-Agent': 'Fleetie pie', + 'Authorization': `token ${sails.config.custom.githubAccessToken}` + }; if (!sails.config.custom.openAiSecret) { throw new Error('sails.config.custom.openAiSecret not set. Cannot respond with haiku.'); @@ -219,7 +223,7 @@ module.exports = { // Now that we know what to say, add our comment. await sails.helpers.http.post('https://api.github.com/repos/'+encodeURIComponent(owner)+'/'+encodeURIComponent(repo)+'/issues/'+encodeURIComponent(issueNumber)+'/comments', {'body': newBotComment}, - {'Authorization': 'token '+sails.config.custom.githubAccessToken} + baseHeadersForGithubApiRequests ); } else if (