Skip to content

Commit

Permalink
Merge branch 'fix-sitemap-user-agent' of github.com:adobe/spacecat-au…
Browse files Browse the repository at this point in the history
…dit-worker into fix-sitemap-user-agent
  • Loading branch information
alinarublea committed Feb 6, 2025
2 parents 4c51ef2 + 2f2dc6f commit dbafed8
Show file tree
Hide file tree
Showing 8 changed files with 1,452 additions and 80 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [1.51.9](https://github.com/adobe/spacecat-audit-worker/compare/v1.51.8...v1.51.9) (2025-02-06)


### Bug Fixes

* error propagation in handlers ([#632](https://github.com/adobe/spacecat-audit-worker/issues/632)) ([2105c77](https://github.com/adobe/spacecat-audit-worker/commit/2105c7771f397b9f61bc92b27d646835b46360e0))

## [1.51.8](https://github.com/adobe/spacecat-audit-worker/compare/v1.51.7...v1.51.8) (2025-02-06)


### Bug Fixes

* **deps:** update adobe fixes ([#635](https://github.com/adobe/spacecat-audit-worker/issues/635)) ([4f2e49f](https://github.com/adobe/spacecat-audit-worker/commit/4f2e49f2caf9335ab75260a2ebbf0adc6dc7ec0f))

## [1.51.7](https://github.com/adobe/spacecat-audit-worker/compare/v1.51.6...v1.51.7) (2025-02-04)


### Bug Fixes

* use urls_suggested as the suggested fix for sitemap redirects ([#629](https://github.com/adobe/spacecat-audit-worker/issues/629)) ([3ef076b](https://github.com/adobe/spacecat-audit-worker/commit/3ef076b3dc1ceaeeefcd5cdf620b46acb6fc1785))

## [1.51.6](https://github.com/adobe/spacecat-audit-worker/compare/v1.51.5...v1.51.6) (2025-02-04)


### Bug Fixes

* user agent for sitemap ([#628](https://github.com/adobe/spacecat-audit-worker/issues/628)) ([70eced9](https://github.com/adobe/spacecat-audit-worker/commit/70eced926df663cc01bdf31d4bea79e47e81a446))

## [1.51.5](https://github.com/adobe/spacecat-audit-worker/compare/v1.51.4...v1.51.5) (2025-02-03)


Expand Down
1,451 changes: 1,400 additions & 51 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-audit-worker",
"version": "1.51.5",
"version": "1.51.9",
"description": "SpaceCat Audit Worker",
"main": "src/index.js",
"type": "module",
Expand Down Expand Up @@ -71,7 +71,7 @@
"@adobe/spacecat-shared-http-utils": "1.9.6",
"@adobe/spacecat-shared-rum-api-client": "2.19.1",
"@adobe/spacecat-shared-rum-api-client-v1": "npm:@adobe/[email protected]",
"@adobe/spacecat-shared-utils": "1.29.0",
"@adobe/spacecat-shared-utils": "1.30.0",
"@aws-sdk/client-s3": "3.740.0",
"@aws-sdk/client-lambda": "3.738.0",
"@aws-sdk/credential-provider-node": "3.738.0",
Expand All @@ -84,14 +84,14 @@
"urijs": "1.19.11"
},
"devDependencies": {
"@adobe/eslint-config-helix": "2.0.8",
"@adobe/helix-deploy": "12.4.11",
"@adobe/eslint-config-helix": "2.0.9",
"@adobe/helix-deploy": "12.4.14",
"@adobe/helix-universal": "5.0.8",
"@adobe/semantic-release-coralogix": "1.1.34",
"@adobe/semantic-release-skms-cmr": "1.1.5",
"@redocly/cli": "1.28.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "6.0.3",
"@semantic-release/exec": "7.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "12.0.1",
"@typescript-eslint/eslint-plugin": "8.22.0",
Expand Down
13 changes: 4 additions & 9 deletions src/backlinks/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ export const isFixedSuggestion = async (suggestion) => {

async function filterOutValidBacklinks(backlinks, log) {
const isStillBrokenBacklink = async (backlink) => {
try {
const response = await fetchWithTimeout(backlink.url_to, TIMEOUT, log);
if (!response.ok && response.status !== 404
const response = await fetchWithTimeout(backlink.url_to, TIMEOUT);
if (!response.ok && response.status !== 404
&& response.status >= 400 && response.status < 500) {
log.warn(`Backlink ${backlink.url_to} returned status ${response.status}`);
}
return !response.ok;
} catch (error) {
log.error(`Failed to check backlink ${backlink.url_to}: ${error.message}`);
return true;
log.warn(`Backlink ${backlink.url_to} returned status ${response.status}`);
}
return !response.ok;
};

const backlinkStatuses = await Promise.all(backlinks.map(isStillBrokenBacklink));
Expand Down
2 changes: 1 addition & 1 deletion src/common/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Audit {

return ok();
} catch (e) {
throw new Error(`${type} audit failed for site ${siteId}. Reason: ${e.message}`);
throw new Error(`${type} audit failed for site ${siteId}. Reason: ${e.message}`, { cause: e });
}
}
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function run(message, context) {

return result;
} catch (e) {
log.error(`${type} audit for ${siteId} failed after ${getElapsedSeconds(startTime)} seconds`, e);
log.error(`${type} audit for ${siteId} failed after ${getElapsedSeconds(startTime)} seconds. `, e);
return internalServerError();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/sitemap/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export async function filterValidUrls(urls) {
acc.notOk.push({
url: result.url,
statusCode: result.statusCode,
...(result.finalUrl && { suggestedFix: result.finalUrl }),
...(result.finalUrl && { urls_suggested: result.finalUrl }),
});
}
return acc;
Expand Down Expand Up @@ -495,7 +495,7 @@ export function getPagesWithIssues(auditData) {
sitemapUrl,
pageUrl: page.url,
statusCode: page.statusCode ?? 500,
...(page.suggestedFix && { suggestedFix: page.suggestedFix }),
...(page.urls_suggested && { urls_suggested: page.urls_suggested }),
}));
});
}
Expand All @@ -521,8 +521,8 @@ export function generateSuggestions(auditUrl, auditData, context) {
.filter(Boolean)
.map((issue) => ({
...issue,
recommendedAction: issue.suggestedFix
? `use this url instead: ${issue.suggestedFix}`
recommendedAction: issue.urls_suggested
? `use this url instead: ${issue.urls_suggested}`
: 'Make sure your sitemaps only include URLs that return the 200 (OK) response code.',
}));

Expand Down
18 changes: 9 additions & 9 deletions test/audits/sitemap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ describe('Sitemap Audit', () => {
});
});

it('should create redirect recommendation when suggestedFix is present', () => {
it('should create redirect recommendation when urls_suggested is present', () => {
const auditDataWithRedirect = {
siteId: 'site-id',
id: 'audit-id',
Expand All @@ -796,7 +796,7 @@ describe('Sitemap Audit', () => {
{
url: 'https://example.com/old-page',
statusCode: 301,
suggestedFix: 'https://example.com/new-page',
urls_suggested: 'https://example.com/new-page',
},
],
},
Expand All @@ -815,7 +815,7 @@ describe('Sitemap Audit', () => {
sitemapUrl: 'https://example.com/sitemap.xml',
pageUrl: 'https://example.com/old-page',
statusCode: 301,
suggestedFix: 'https://example.com/new-page',
urls_suggested: 'https://example.com/new-page',
recommendedAction: 'use this url instead: https://example.com/new-page',
});
});
Expand Down Expand Up @@ -1072,12 +1072,12 @@ describe('filterValidUrls with redirect handling', () => {
{
url: 'https://example.com/permanent-redirect',
statusCode: 301,
suggestedFix: 'https://example.com/new-location',
urls_suggested: 'https://example.com/new-location',
},
{
url: 'https://example.com/temporary-redirect',
statusCode: 302,
suggestedFix: 'https://example.com/temp-location',
urls_suggested: 'https://example.com/temp-location',
},
{
url: 'https://example.com/not-found',
Expand All @@ -1102,15 +1102,15 @@ describe('filterValidUrls with redirect handling', () => {
expect(result.notOk).to.deep.equal([
{
url: 'https://example.com/broken-redirect',
suggestedFix: 'https://example.com/error',
urls_suggested: 'https://example.com/error',
statusCode: 301,
},
]);
});
});

describe('getPagesWithIssues', () => {
it('should include suggestedFix in the output when present in the input', () => {
it('should include urls_suggested in the output when present in the input', () => {
const auditData = {
auditResult: {
details: {
Expand All @@ -1119,7 +1119,7 @@ describe('getPagesWithIssues', () => {
{
url: 'https://example.com/old-page',
statusCode: 301,
suggestedFix: 'https://example.com/new-page',
urls_suggested: 'https://example.com/new-page',
},
{
url: 'https://example.com/not-found',
Expand All @@ -1138,7 +1138,7 @@ describe('getPagesWithIssues', () => {
sitemapUrl: 'https://example.com/sitemap.xml',
pageUrl: 'https://example.com/old-page',
statusCode: 301,
suggestedFix: 'https://example.com/new-page',
urls_suggested: 'https://example.com/new-page',
});
expect(result[1]).to.deep.equal({
type: 'url',
Expand Down

0 comments on commit dbafed8

Please sign in to comment.