Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(branding): stop returning internal fields in the branding response (#4883)

Abimael Martell76abc3e56066
diff --git a/apps/api/src/__tests__/snips/v2/scrape-branding.test.ts b/apps/api/src/__tests__/snips/v2/scrape-branding.test.ts
index 2b306a0d3..3db906a95 100644
--- a/apps/api/src/__tests__/snips/v2/scrape-branding.test.ts
+++ b/apps/api/src/__tests__/snips/v2/scrape-branding.test.ts
@@ -148,6 +148,31 @@ describe("Branding with Jev", () => {
);
});
+describe("Branding response", () => {
+ concurrentIf(TEST_PRODUCTION)(
+ "returns no internal fields to teams that aren't debugging branding",
+ async () => {
+ const response = await scrape(
+ {
+ url: "https://firecrawl-test-site.vercel.app/",
+ formats: ["branding"],
+ timeout: scrapeTimeout,
+ },
+ identity,
+ );
+
+ expect(response.branding).toBeDefined();
+ // Still a real extraction, not an empty object.
+ expect(response.branding?.logo).toContain("firecrawl");
+ expect(response.branding?.colors?.primary).toMatch(/^#[0-9A-F]{6}$/);
+ expect(
+ Object.keys(response.branding!).filter(key => key.startsWith("__")),
+ ).toEqual([]);
+ },
+ scrapeTimeout,
+ );
+});
+
const PDF_URL = "https://www.orimi.com/pdf-test.pdf";
describe("Branding on pages it can't run on", () => {
diff --git a/apps/api/src/lib/branding/transformer.ts b/apps/api/src/lib/branding/transformer.ts
index df183ce84..a94319e9c 100644
--- a/apps/api/src/lib/branding/transformer.ts
+++ b/apps/api/src/lib/branding/transformer.ts
@@ -457,11 +457,12 @@ export async function brandingTransformer(
});
}
+ // Every `__` key (page snapshots, logo candidates, LLM reasoning and
+ // metadata) is internal; only teams debugging branding get them back.
if (!isDebugBrandingEnabled(meta)) {
- delete (brandingProfile as any).__button_snapshots;
- delete (brandingProfile as any).__input_snapshots;
- delete (brandingProfile as any).__logo_candidates;
- delete (brandingProfile as any).__framework_hints;
+ for (const key of Object.keys(brandingProfile)) {
+ if (key.startsWith("__")) delete (brandingProfile as any)[key];
+ }
}
if (brandName) {