From ad77c9bfa3b026a1bd69d8bf31de4c5eeb00e2ab Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 05:33:02 -0300 Subject: [PATCH 1/7] fix(vtex): handle 400 errors in pageTypesFromUrl gracefully When VTEX Catalog API returns a 400 for invalid URL segments (e.g. bot probes like /%252f/backend/.env), the error was propagating and breaking section rendering. Return { pageType: "NotFound" } on failure so getValidTypesFromPageTypes filters it out and the loader returns null cleanly. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- vtex/utils/intelligentSearch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vtex/utils/intelligentSearch.ts b/vtex/utils/intelligentSearch.ts index 482b33f7a..decf026f4 100644 --- a/vtex/utils/intelligentSearch.ts +++ b/vtex/utils/intelligentSearch.ts @@ -148,7 +148,7 @@ export const pageTypesFromUrl = async ( segments.map((_, index) => vcsDeprecated["GET /api/catalog_system/pub/portal/pagetype/:term"]({ term: segments.slice(0, index + 1).join("/"), - }, STALE).then((res) => res.json()) + }, STALE).then((res) => res.json()).catch(() => ({ pageType: "NotFound" })) ), ); }; From f84771db162baa252bef928a20bbf18079f6662f Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 05:38:55 -0300 Subject: [PATCH 2/7] fix(vtex): only swallow 400 errors in pageTypesFromUrl Co-Authored-By: Claude Sonnet 4.6 (1M context) --- vtex/utils/intelligentSearch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vtex/utils/intelligentSearch.ts b/vtex/utils/intelligentSearch.ts index decf026f4..7ad89f67c 100644 --- a/vtex/utils/intelligentSearch.ts +++ b/vtex/utils/intelligentSearch.ts @@ -148,7 +148,10 @@ export const pageTypesFromUrl = async ( segments.map((_, index) => vcsDeprecated["GET /api/catalog_system/pub/portal/pagetype/:term"]({ term: segments.slice(0, index + 1).join("/"), - }, STALE).then((res) => res.json()).catch(() => ({ pageType: "NotFound" })) + }, STALE).then((res) => res.json()).catch((e) => { + if (e?.status === 400) return { pageType: "NotFound" }; + throw e; + }) ), ); }; From 1e0e48848617de1edaf7b8b66421c31662115c1d Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 05:56:07 -0300 Subject: [PATCH 3/7] fix(vtex): return full PageType object to satisfy TypeScript Co-Authored-By: Claude Sonnet 4.6 (1M context) --- vtex/utils/intelligentSearch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vtex/utils/intelligentSearch.ts b/vtex/utils/intelligentSearch.ts index 7ad89f67c..b006ccd67 100644 --- a/vtex/utils/intelligentSearch.ts +++ b/vtex/utils/intelligentSearch.ts @@ -1,6 +1,7 @@ import { AppContext } from "../mod.ts"; import { STALE } from "../../utils/fetch.ts"; import type { + PageType, SelectedFacet, SimulationBehavior, Sort, @@ -149,7 +150,9 @@ export const pageTypesFromUrl = async ( vcsDeprecated["GET /api/catalog_system/pub/portal/pagetype/:term"]({ term: segments.slice(0, index + 1).join("/"), }, STALE).then((res) => res.json()).catch((e) => { - if (e?.status === 400) return { pageType: "NotFound" }; + if (e?.status === 400) { + return { id: null, name: null, url: null, title: null, metaTagDescription: null, pageType: "NotFound" } satisfies PageType; + } throw e; }) ), From bcd89833344fb2f84de89771e45502d260d2a0a3 Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 05:57:21 -0300 Subject: [PATCH 4/7] fix(vtex): deno fmt Co-Authored-By: Claude Sonnet 4.6 (1M context) --- vtex/utils/intelligentSearch.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vtex/utils/intelligentSearch.ts b/vtex/utils/intelligentSearch.ts index b006ccd67..757d46421 100644 --- a/vtex/utils/intelligentSearch.ts +++ b/vtex/utils/intelligentSearch.ts @@ -151,7 +151,14 @@ export const pageTypesFromUrl = async ( term: segments.slice(0, index + 1).join("/"), }, STALE).then((res) => res.json()).catch((e) => { if (e?.status === 400) { - return { id: null, name: null, url: null, title: null, metaTagDescription: null, pageType: "NotFound" } satisfies PageType; + return { + id: null, + name: null, + url: null, + title: null, + metaTagDescription: null, + pageType: "NotFound", + } satisfies PageType; } throw e; }) From a778a6530ad9800eadf001dbe831065eb0b82d24 Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 06:00:19 -0300 Subject: [PATCH 5/7] fix(http): remove RequestInit import from @deco/deco (removed in 1.188.0) RequestInit is a global Deno/Web API type, no import needed. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- utils/http.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/http.ts b/utils/http.ts index 69432b8f0..95159e379 100644 --- a/utils/http.ts +++ b/utils/http.ts @@ -1,4 +1,3 @@ -import { type RequestInit } from "@deco/deco"; import { fetchSafe } from "./fetch.ts"; // Check if DEBUG_HTTP env var is set From 405d539c3e93b02c26ad4bcde07ee2791025dc77 Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 06:07:31 -0300 Subject: [PATCH 6/7] Revert "fix(http): remove RequestInit import from @deco/deco (removed in 1.188.0)" This reverts commit a778a6530ad9800eadf001dbe831065eb0b82d24. --- utils/http.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/http.ts b/utils/http.ts index 95159e379..69432b8f0 100644 --- a/utils/http.ts +++ b/utils/http.ts @@ -1,3 +1,4 @@ +import { type RequestInit } from "@deco/deco"; import { fetchSafe } from "./fetch.ts"; // Check if DEBUG_HTTP env var is set From fe1d2acb82df634f5fafce93aeab011079f1db59 Mon Sep 17 00:00:00 2001 From: igoramf Date: Wed, 1 Apr 2026 06:08:37 -0300 Subject: [PATCH 7/7] fix(http): replace RequestInit from @deco/deco with DecoRequestInit from fetch.ts @deco/deco removed RequestInit from its exports in 1.188.0. DecoRequestInit from fetch.ts is the same type (RequestInit & { deco? }). Co-Authored-By: Claude Sonnet 4.6 (1M context) --- utils/http.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/http.ts b/utils/http.ts index 69432b8f0..e294170f7 100644 --- a/utils/http.ts +++ b/utils/http.ts @@ -1,5 +1,4 @@ -import { type RequestInit } from "@deco/deco"; -import { fetchSafe } from "./fetch.ts"; +import { type DecoRequestInit as RequestInit, fetchSafe } from "./fetch.ts"; // Check if DEBUG_HTTP env var is set const DEBUG_HTTP = Deno.env.get("DEBUG_HTTP") === "true";