Fix CodeQL errors

This commit is contained in:
lowlighter
2021-04-14 18:52:56 +02:00
parent 8cba3f449a
commit 1fb6eb166c

View File

@@ -200,7 +200,7 @@
//GitHub failed request //GitHub failed request
if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) { if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) {
console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`) console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`)
const {request} = error.errors[0].message.match(/`(?<request>[\w:]+)`/)?.groups ?? null const request = encodeURIComponent(error.errors[0].message.match(/`(?<request>[\w:]+)`/)?.groups?.request ?? "").replace(/%3A/g, ":")
return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`) return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`)
} }
//General error //General error
@@ -288,7 +288,7 @@
//GitHub failed request //GitHub failed request
if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) { if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) {
console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`) console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`)
const {request} = error.errors[0].message.match(/`(?<request>[\w:]+)`/)?.groups ?? null const request = encodeURIComponent(error.errors[0].message.match(/`(?<request>[\w:]+)`/)?.groups?.request ?? "").replace(/%3A/g, ":")
return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`) return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`)
} }
//General error //General error