From d4220ec8821416576c189590488dd5ae4dcd1826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20J=C3=A4ggi?= Date: Tue, 5 Dec 2023 11:30:33 +0100 Subject: [PATCH] fix: update to latest data-access, process response status --- package-lock.json | 16 ++++++++-------- package.json | 2 +- src/support/github-client.js | 10 ++++------ test/support/github-client.test.js | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 503bf7d2..314b9b1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@adobe/helix-shared-wrap": "2.0.0", "@adobe/helix-status": "10.0.10", "@adobe/helix-universal-logger": "3.0.11", - "@adobe/spacecat-shared-data-access": "1.1.2", + "@adobe/spacecat-shared-data-access": "1.1.3", "@adobe/spacecat-shared-utils": "1.2.0", "@aws-sdk/client-sqs": "3.450.0", "diff": "5.1.0" @@ -261,11 +261,11 @@ } }, "node_modules/@adobe/spacecat-shared-data-access": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-data-access/-/spacecat-shared-data-access-1.1.2.tgz", - "integrity": "sha512-iRX5RtMzSYIHOJoud3fkKzmtBInadaQkc5IN/V4QD0fycbbAcfPmX9SX8F7Yz/jeSvkOSCuZIFaZZ5VRjCAarQ==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-data-access/-/spacecat-shared-data-access-1.1.3.tgz", + "integrity": "sha512-Xs8gA7BQ1wLgCBcfxv9NOfibOSKPgkJ+9+YTYjnU2GRYxC35FIqUYsKUW68a6k55ADL3wKroGIKYxp9E615Ksw==", "dependencies": { - "@adobe/spacecat-shared-dynamo": "1.2.3", + "@adobe/spacecat-shared-dynamo": "1.2.4", "@adobe/spacecat-shared-utils": "1.2.0", "@aws-sdk/client-dynamodb": "3.465.0", "@aws-sdk/lib-dynamodb": "3.465.0", @@ -285,9 +285,9 @@ } }, "node_modules/@adobe/spacecat-shared-dynamo": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-dynamo/-/spacecat-shared-dynamo-1.2.3.tgz", - "integrity": "sha512-ord82ihIg58lDjXJwfLTERSRidgpVHwLxCG5g5LX1HWUu51o/Hvch0L2uTEHR0QKBE5e3xuG0SQe0nZtscw8cA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-dynamo/-/spacecat-shared-dynamo-1.2.4.tgz", + "integrity": "sha512-KN9as8JXuofnHPIKgvaIyLgI3FIKECwLTybzDW1aGxC4iWbh9EJywSR0WTUvAr3WU8vka0QzPZDvOyy3Wko3Gw==", "dependencies": { "@adobe/spacecat-shared-utils": "1.1.0", "@aws-sdk/client-dynamodb": "3.465.0", diff --git a/package.json b/package.json index 96dedb6d..56c19892 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@adobe/helix-shared-wrap": "2.0.0", "@adobe/helix-status": "10.0.10", "@adobe/helix-universal-logger": "3.0.11", - "@adobe/spacecat-shared-data-access": "1.1.2", + "@adobe/spacecat-shared-data-access": "1.1.3", "@adobe/spacecat-shared-utils": "1.2.0", "@aws-sdk/client-sqs": "3.450.0", "diff": "5.1.0" diff --git a/src/support/github-client.js b/src/support/github-client.js index fab3cd9d..df524472 100644 --- a/src/support/github-client.js +++ b/src/support/github-client.js @@ -125,12 +125,10 @@ function GithubClient( }); let responseJson; - try { - const text = await response.text(); - log.info(`Parsing GitHub response for site ${baseURL}: \n ${text}`); - responseJson = JSON.parse(text); - } catch (error) { - log.error(`Error parsing GitHub response for site ${baseURL}: ${error}`); + if (response.status === 200) { + responseJson = await response.json(); + } else { + log.error(`Error fetching GitHub diff data for site ${baseURL}: ${response.status} ${response.statusText}`); return ''; } diff --git a/test/support/github-client.test.js b/test/support/github-client.test.js index 7ea0b300..1340f192 100644 --- a/test/support/github-client.test.js +++ b/test/support/github-client.test.js @@ -110,7 +110,7 @@ describe('GithubClient', () => { nock('https://api.github.com') .get('/repos/some-org/test/commits') .query(true) - .reply(200, 'invalid-response'); + .reply(405); const diffs = await client.fetchGithubDiff('example.com', audit.time, lastAuditedAt, gitHubURL); expect(diffs).to.equal('');