diff --git a/src/metatags/handler.js b/src/metatags/handler.js index 942b217a..33a7e634 100644 --- a/src/metatags/handler.js +++ b/src/metatags/handler.js @@ -20,7 +20,11 @@ import SeoChecks from './seo-checks.js'; async function fetchAndProcessPageObject(s3Client, bucketName, key, prefix, log) { const object = await getObjectFromKey(s3Client, bucketName, key, log); if (!object?.scrapeResult?.tags || typeof object.scrapeResult.tags !== 'object') { - log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)}`); + if (object && object.scrapeResult) { + log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)} & type ${typeof object.scrapeResult.tags}`); + } else { + log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)}`); + } return null; } const pageUrl = key.slice(prefix.length - 1).replace('scrape.json', ''); // Remove the prefix and .json suffix diff --git a/test/audits/metatags.test.js b/test/audits/metatags.test.js index 1fbe5595..a66e924a 100644 --- a/test/audits/metatags.test.js +++ b/test/audits/metatags.test.js @@ -534,7 +534,9 @@ describe('Meta Tags', () => { .returns({ Body: { transformToString: () => JSON.stringify({ - tags: 5, + scrapeResult: { + tags: 5, + }, }), }, });