From 1d83cbbc4bc2d37e388e1c6d75e222f3caa644ad Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 2 Sep 2020 09:19:50 +0200 Subject: [PATCH] fix(github): massage url and message in errors (#7160) --- lib/util/http/github.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index aacc666d75..993b14cb62 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -1,4 +1,5 @@ import URL from 'url'; +import is from '@sindresorhus/is'; import pAll from 'p-all'; import parseLinkHeader from 'parse-link-header'; import { @@ -43,8 +44,8 @@ function handleGotError( ): never { const path = url.toString(); let message = err.message || ''; - if (err.body?.message) { - message = err.body.message; + if (is.plainObject(err.response?.body) && 'message' in err.response.body) { + message = String(err.response.body.message); } if ( err.name === 'RequestError' && @@ -114,7 +115,7 @@ function handleGotError( throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); } if (err.statusCode === 404) { - logger.debug({ url: err.options?.url }, 'GitHub 404'); + logger.debug({ url: path }, 'GitHub 404'); } else { logger.debug({ err }, 'Unknown GitHub error'); } -- GitLab