From 1c34bf260d898cc59d252baf0037b5f286dea7db Mon Sep 17 00:00:00 2001 From: Divyansh Pratap Date: Tue, 3 Mar 2026 12:25:07 +0530 Subject: [PATCH 1/4] fix: add more edge logging --- src/controllers/suggestions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/controllers/suggestions.js b/src/controllers/suggestions.js index 5253227e2..1e405719c 100644 --- a/src/controllers/suggestions.js +++ b/src/controllers/suggestions.js @@ -1281,7 +1281,6 @@ function SuggestionsController(ctx, sqs, env) { const domainWideSuggestions = []; const failedSuggestions = []; let coveredSuggestionsCount = 0; - // Check each requested suggestion (basic validation only) suggestionIds.forEach((suggestionId, index) => { const suggestion = allSuggestions.find((s) => s.getId() === suggestionId); @@ -1322,6 +1321,8 @@ function SuggestionsController(ctx, sqs, env) { validSuggestions.push(suggestion); } }); + context.log.info(`[edge-deploy] validSuggestions count: ${validSuggestions.length} + , Failed suggestions count: ${failedSuggestions.length}`); // Filter out validSuggestions that are covered by domain-wide suggestions // in the same deployment @@ -1422,6 +1423,8 @@ function SuggestionsController(ctx, sqs, env) { // Add ineligible suggestions to failed list ineligibleSuggestions.forEach((item) => { + context.log.info(`[edge-deploy-failed] site: ${apexBaseUrl}, ${opportunity.getType()}` + + ` suggestion ${item.suggestion.getId()} is ineligible: ${item.reason}`); failedSuggestions.push({ uuid: item.suggestion.getId(), index: suggestionIds.indexOf(item.suggestion.getId()), @@ -1447,6 +1450,7 @@ function SuggestionsController(ctx, sqs, env) { // Handle domain-wide suggestions separately if (isNonEmptyArray(domainWideSuggestions)) { + context.log.info(`[edge-deploy] domainWideSuggestions count: ${domainWideSuggestions.length}`); try { const tokowakaClient = TokowakaClient.createFrom(context); const baseURL = site.getBaseURL(); @@ -1621,7 +1625,7 @@ function SuggestionsController(ctx, sqs, env) { // Add to succeeded suggestions list for response succeededSuggestions.push(...skippedSuggestionEntities); } catch (error) { - context.log.error(`Error marking skipped suggestions: ${error.message}`, error); + context.log.error(`[edge-deploy-failed] site: ${apexBaseUrl}, Error marking skipped suggestions: ${error.message}`, error); // Add to failed if we couldn't mark them context.skippedDueToSameBatchDomainWide.forEach((skipped) => { failedSuggestions.push({ @@ -1746,7 +1750,8 @@ function SuggestionsController(ctx, sqs, env) { } } }); - + context.log.info(`[edge-rollback] validSuggestions count: ${validSuggestions.length}, + failedSuggestions count: ${failedSuggestions.length}`); let succeededSuggestions = []; // Separate domain-wide from regular suggestions @@ -1870,6 +1875,8 @@ function SuggestionsController(ctx, sqs, env) { // Add ineligible suggestions to failed list ineligibleSuggestions.forEach((item) => { + context.log.info(`[edge-rollback-failed] site: ${apexBaseUrl}, ${opportunity.getType()}` + + ` suggestion ${item.suggestion.getId()} is ineligible: ${item.reason}`); failedSuggestions.push({ uuid: item.suggestion.getId(), index: suggestionIds.indexOf(item.suggestion.getId()), From 010aeec1487301bbef9161f028ac93c95149ccc4 Mon Sep 17 00:00:00 2001 From: Divyansh Pratap Date: Mon, 9 Mar 2026 02:02:53 +0530 Subject: [PATCH 2/4] fix: preview api optimization --- package-lock.json | 30 +++++++++++++++++++++++++++--- package.json | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2673839de..3fe70f4aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "@adobe/spacecat-shared-scrape-client": "2.5.3", "@adobe/spacecat-shared-slack-client": "1.6.2", "@adobe/spacecat-shared-tier-client": "1.3.15", - "@adobe/spacecat-shared-tokowaka-client": "1.10.2", + "@adobe/spacecat-shared-tokowaka-client": "https://gist.github.com/dipratap/c893e5f937a62e34bee0a889b0b5287b/raw/596892b715f29656469f883eee19cc8bb7d096e7/adobe-spacecat-shared-tokowaka-client-1.10.2.tgz", "@adobe/spacecat-shared-utils": "1.100.1", "@adobe/spacecat-shared-vault-secrets": "1.1.1", "@aws-sdk/client-s3": "3.1004.0", @@ -792,6 +792,7 @@ "resolved": "https://registry.npmjs.org/@adobe/helix-universal/-/helix-universal-5.4.0.tgz", "integrity": "sha512-3ZfFdjYtpv7RCgul9yyOBsRVsxLNapwt0YjASBhyzJGNjnPxrWDlqDtbpBdwAgA1Nuh9nmjzFDFu8CJWv6BMKw==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@adobe/fetch": "4.2.3", "aws4": "1.13.2" @@ -6835,8 +6836,8 @@ }, "node_modules/@adobe/spacecat-shared-tokowaka-client": { "version": "1.10.2", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-tokowaka-client/-/spacecat-shared-tokowaka-client-1.10.2.tgz", - "integrity": "sha512-bYZ0vKXJ/LnZuSigUgoJbDZ2DGF7iYZ+f7u+wzuV7bGidpQVTF2T1HwhG4s7nNK6RqR2hDVqvzDIOLnnW8QenA==", + "resolved": "https://gist.github.com/dipratap/c893e5f937a62e34bee0a889b0b5287b/raw/596892b715f29656469f883eee19cc8bb7d096e7/adobe-spacecat-shared-tokowaka-client-1.10.2.tgz", + "integrity": "sha512-1+9t9XYvr3ZSZ18mVV6cqOSb+y+Jdp7Z1ZeO3JtAq0E+pzTgCKvR7SZuAtCSx7tUGDpjuRy7YqtSccVxt6j29A==", "license": "Apache-2.0", "dependencies": { "@adobe/spacecat-shared-utils": "1.81.1", @@ -8097,6 +8098,7 @@ "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.940.0.tgz", "integrity": "sha512-u2sXsNJazJbuHeWICvsj6RvNyJh3isedEfPvB21jK/kxcriK+dE/izlKC2cyxUjERCmku0zTFNzY9FhrLbYHjQ==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -12360,6 +12362,7 @@ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.80.tgz", "integrity": "sha512-vcJDV2vk1AlCwSh3aBm/urQ1ZrlXFFBocv11bz/NBUfLWD5/UDNMzwPdaAd2dKvNmTWa9FM2lirLU3+JCf4cRA==", "license": "MIT", + "peer": true, "dependencies": { "@cfworker/json-schema": "^4.0.2", "ansi-styles": "^5.0.0", @@ -12591,6 +12594,7 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", "license": "MIT", + "peer": true, "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.3", @@ -12797,6 +12801,7 @@ "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=8.0.0" } @@ -12960,6 +12965,7 @@ "integrity": "sha512-xYLlvk/xdScGx1aEqvxLwf6sXQLXCjk3/1SQT9X9AoN5rXRhkdvIFShuNNmtTEPRBqcsMbS4p/gJLNI2wXaDuQ==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.0.1", "@opentelemetry/resources": "2.0.1", @@ -14942,6 +14948,7 @@ "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", "license": "MIT", + "peer": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -15248,6 +15255,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -15294,6 +15302,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -15769,6 +15778,7 @@ "resolved": "https://registry.npmjs.org/aws-xray-sdk-core/-/aws-xray-sdk-core-3.12.0.tgz", "integrity": "sha512-lwalRdxXRy+Sn49/vN7W507qqmBRk5Fy2o0a9U6XTjL9IV+oR5PUiiptoBrOcaYCiVuGld8OEbNqhm6wvV3m6A==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@aws-sdk/types": "^3.4.1", "@smithy/service-error-classification": "^2.0.4", @@ -16419,6 +16429,7 @@ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -18608,6 +18619,7 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -22602,6 +22614,7 @@ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", "dev": true, "license": "MIT", + "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -23657,6 +23670,7 @@ "integrity": "sha512-UczzB+0nnwGotYSgllfARAqWCJ5e/skuV2K/l+Zyck/H6pJIhLXuBnz+6vn2i211o7DtbE78HQtsYEKICHGI+g==", "dev": true, "license": "MIT", + "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/mobx" @@ -26829,6 +26843,7 @@ "dev": true, "inBundle": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -27498,6 +27513,7 @@ "resolved": "https://registry.npmjs.org/openai/-/openai-5.12.2.tgz", "integrity": "sha512-xqzHHQch5Tws5PcKR2xsZGX9xtch+JQFz5zb14dGqlshmmDAFBFEWmeIpf7wVqWV+w7Emj7jRgkNJakyKE0tYQ==", "license": "Apache-2.0", + "peer": true, "bin": { "openai": "bin/cli" }, @@ -28590,6 +28606,7 @@ "integrity": "sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==", "devOptional": true, "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -28600,6 +28617,7 @@ "integrity": "sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -29309,6 +29327,7 @@ "integrity": "sha512-phCkJ6pjDi9ANdhuF5ElS10GGdAKY6R1Pvt9lT3SFhOwM4T7QZE7MLpBDbNruUx/Q3gFD92/UOFringGipRqZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@semantic-release/commit-analyzer": "^13.0.0-beta.1", "@semantic-release/error": "^4.0.0", @@ -30770,6 +30789,7 @@ "integrity": "sha512-J72R4ltw0UBVUlEjTzI0gg2STOqlI9JBhQOL4Dxt7aJOnnSesy0qJDn4PYfMCafk9cWOaVg129Pesl5o+DIh0Q==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@emotion/is-prop-valid": "1.4.0", "@emotion/unitless": "0.10.0", @@ -31852,6 +31872,7 @@ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", "license": "MIT", + "peer": true, "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", @@ -32576,6 +32597,7 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", "license": "MIT", + "peer": true, "engines": { "node": ">=10.0.0" }, @@ -32840,6 +32862,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -32849,6 +32872,7 @@ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz", "integrity": "sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==", "license": "ISC", + "peer": true, "peerDependencies": { "zod": "^3.25 || ^4" } diff --git a/package.json b/package.json index 77bf7a370..b9f320423 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@adobe/spacecat-shared-scrape-client": "2.5.3", "@adobe/spacecat-shared-slack-client": "1.6.2", "@adobe/spacecat-shared-tier-client": "1.3.15", - "@adobe/spacecat-shared-tokowaka-client": "1.10.2", + "@adobe/spacecat-shared-tokowaka-client": "https://gist.github.com/dipratap/c893e5f937a62e34bee0a889b0b5287b/raw/596892b715f29656469f883eee19cc8bb7d096e7/adobe-spacecat-shared-tokowaka-client-1.10.2.tgz", "@adobe/spacecat-shared-utils": "1.100.1", "@adobe/spacecat-shared-vault-secrets": "1.1.1", "@aws-sdk/client-s3": "3.1004.0", From 8c0aabbd9736c351635bc44086c903c9a7ceed39 Mon Sep 17 00:00:00 2001 From: Divyansh Pratap Date: Mon, 9 Mar 2026 02:05:06 +0530 Subject: [PATCH 3/4] fix: preview api optimization --- src/controllers/suggestions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/suggestions.js b/src/controllers/suggestions.js index a8db5a521..f00fbb38d 100644 --- a/src/controllers/suggestions.js +++ b/src/controllers/suggestions.js @@ -1344,6 +1344,7 @@ function SuggestionsController(ctx, sqs, env) { const domainWideSuggestions = []; const failedSuggestions = []; let coveredSuggestionsCount = 0; + // Check each requested suggestion (basic validation only) suggestionIds.forEach((suggestionId, index) => { const suggestion = allSuggestions.find((s) => s.getId() === suggestionId); From b5cc5278dad4764a98c3b7afc2e3c9fecafbfe3f Mon Sep 17 00:00:00 2001 From: Divyansh Pratap Date: Mon, 9 Mar 2026 02:13:35 +0530 Subject: [PATCH 4/4] fix: preview api optimization --- test/controllers/suggestions.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/controllers/suggestions.test.js b/test/controllers/suggestions.test.js index 7a8dd5ef1..a89ffbd15 100644 --- a/test/controllers/suggestions.test.js +++ b/test/controllers/suggestions.test.js @@ -6178,14 +6178,15 @@ describe('Suggestions Controller', () => { // Stub global fetch for HTML fetching fetchStub = sandbox.stub(global, 'fetch'); // Mock fetch responses for HTML fetching (warmup + actual for both original and optimized) + // Header must be x-edgeoptimize-cache (no hyphen) to match tokowaka client fetchStub.resolves({ ok: true, status: 200, statusText: 'OK', headers: { get: (headerName) => { - if (headerName === 'x-edge-optimize-cache') { - return 'hit'; + if (headerName === 'x-edgeoptimize-cache') { + return 'HIT'; } return null; },