Skip to content
This repository was archived by the owner on Oct 14, 2026. It is now read-only.

Commit 0f3380e

Browse files
jindaliiitaclaude
andcommitted
fix(tokowaka-client): keep edgeOptimizeEnabled as raw routing signal for now
Don't fold `blocked` into edgeOptimizeEnabled yet — persistEdgeConfig's routingEnabled stamping (import-worker) reads edgeOptimizeEnabled, so gating it on WAF status today would mean a routing-confirmed-but-WAF- blocked site never gets routingEnabled stamped, which would misdirect the frontend's "Configure CDN" vs "running final checks" messaging for that exact case. blocked/statusCode are still classified from the same fetched response and returned + logged, for the frontend to start consuming later, with retiring the separate checkWafConnectivity call as a further follow-up. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 532455c commit 0f3380e

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎packages/spacecat-shared-tokowaka-client/src/index.js‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,14 @@ class TokowakaClient {
13451345
* Fetches the customer's own domain directly (no proxy) and checks the response for
13461346
* BOTH the routing signal (x-tokowaka-request-id / x-edgeoptimize-request-id header)
13471347
* and a WAF/bot-block (via classifyProbeResponse, on the same fetched response — no
1348-
* second request). `edgeOptimizeEnabled` folds both together: it is only `true` when
1349-
* the request-id header is present AND the response isn't classified as blocked —
1350-
* routing alone is not sufficient.
1348+
* second request).
1349+
*
1350+
* `edgeOptimizeEnabled` is still the raw routing signal only (unchanged from before —
1351+
* `blocked` does NOT factor into it yet), to stay fully backward compatible with
1352+
* existing consumers (e.g. the import-worker's routingEnabled stamping). `blocked`/
1353+
* `statusCode` are returned (and logged) purely for visibility for now; consuming them
1354+
* on the frontend, and eventually retiring the separate checkWafConnectivity call in
1355+
* favor of this, is follow-up work.
13511356
*
13521357
* @param {Object} site - Site entity
13531358
* @param {string} path - Path to check (e.g., '/products/chair')
@@ -1407,11 +1412,15 @@ class TokowakaClient {
14071412
this.log.info(`[edge-optimize-status] Edge optimize headers found: ${requestIdPresent} for ${targetUrl}`);
14081413

14091414
// Classify the same response already fetched above for a WAF/bot-block — no second
1410-
// request. edgeOptimizeEnabled folds both signals together: routing alone isn't
1411-
// enough if the customer's own WAF is blocking us.
1415+
// request. Logged/returned for visibility only for now — edgeOptimizeEnabled stays
1416+
// the raw routing signal (does NOT fold in `blocked` yet) so this stays fully
1417+
// backward compatible: persistEdgeConfig's routingEnabled stamping (and everything
1418+
// downstream of it) is untouched. Consuming `blocked`/`statusCode` on the frontend,
1419+
// and eventually retiring the separate checkWafConnectivity call, is follow-up work.
14121420
// eslint-disable-next-line no-await-in-loop
14131421
const { blocked, statusCode } = await classifyProbeResponse(response, targetHost, this.log);
1414-
const edgeOptimizeEnabled = requestIdPresent && !blocked;
1422+
this.log.info(`[edge-optimize-status] WAF classification for ${targetUrl}: blocked=${blocked}, statusCode=${statusCode}`);
1423+
const edgeOptimizeEnabled = requestIdPresent;
14151424

14161425
return {
14171426
edgeOptimizeEnabled,

‎packages/spacecat-shared-tokowaka-client/test/index.test.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5783,7 +5783,7 @@ describe('TokowakaClient', () => {
57835783
});
57845784
});
57855785

5786-
describe('WAF classification merged into routing check', () => {
5786+
describe('WAF classification alongside routing check (logged/returned, not gating yet)', () => {
57875787
let site;
57885788

57895789
beforeEach(() => {
@@ -5795,7 +5795,7 @@ describe('TokowakaClient', () => {
57955795
};
57965796
});
57975797

5798-
it('routing confirmed but hard-blocked (403) → edgeOptimizeEnabled: false, blocked: true', async () => {
5798+
it('routing confirmed but hard-blocked (403) → edgeOptimizeEnabled stays true (raw routing signal), blocked: true reported separately', async () => {
57995799
const headersMap = new Map([
58005800
['x-tokowaka-request-id', 'abc123'],
58015801
]);
@@ -5809,13 +5809,13 @@ describe('TokowakaClient', () => {
58095809
const result = await esmockClient.checkEdgeOptimizeStatus(site, '/');
58105810

58115811
expect(result).to.deep.equal({
5812-
edgeOptimizeEnabled: false,
5812+
edgeOptimizeEnabled: true,
58135813
blocked: true,
58145814
statusCode: 403,
58155815
});
58165816
});
58175817

5818-
it('routing confirmed but soft-blocked (challenge page body) → edgeOptimizeEnabled: false, blocked: true', async () => {
5818+
it('routing confirmed but soft-blocked (challenge page body) → edgeOptimizeEnabled stays true (raw routing signal), blocked: true reported separately', async () => {
58195819
const headersMap = new Map([
58205820
['x-tokowaka-request-id', 'abc123'],
58215821
['content-type', 'text/html'],
@@ -5831,7 +5831,7 @@ describe('TokowakaClient', () => {
58315831
const result = await esmockClient.checkEdgeOptimizeStatus(site, '/');
58325832

58335833
expect(result).to.deep.equal({
5834-
edgeOptimizeEnabled: false,
5834+
edgeOptimizeEnabled: true,
58355835
blocked: true,
58365836
statusCode: 200,
58375837
});

0 commit comments

Comments
 (0)