Skip to content

Commit

Permalink
fix: update to latest data-access, process response status
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Dec 5, 2023
1 parent 5802336 commit d4220ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 4 additions & 6 deletions src/support/github-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down
2 changes: 1 addition & 1 deletion test/support/github-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down

0 comments on commit d4220ec

Please sign in to comment.