firecrawl/open-lovable · error

${brandGuidelines.error || 'Failed to extract brand styles'}

Error message

${brandGuidelines.error || 'Failed to extract brand styles'}

What it means

Application-level variant of the brand-extraction failure: the extraction endpoint returned HTTP 200 but its JSON body has success === false, so brandGuidelines.error (or the fallback text) is thrown. The server reached the target site (or at least handled the request) but its extraction step failed and reported why in the payload.

Source

Thrown at app/generation/page.tsx:2734

          // Call the brand extraction endpoint
          const extractResponse = await fetch('/api/extract-brand-styles', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({
              url,
              prompt: brandExtensionPrompt
            })
          });

          if (!extractResponse.ok) {
            throw new Error('Failed to extract brand styles');
          }

          brandGuidelines = await extractResponse.json();

          if (!brandGuidelines.success) {
            throw new Error(brandGuidelines.error || 'Failed to extract brand styles');
          }

          // Display branding summary with visual UI
          addChatMessage(`Acquired branding format from ${cleanUrl}`, 'system', {
            brandingData: brandGuidelines.guidelines,
            sourceUrl: cleanUrl
          });
          addChatMessage(`Building your custom component using these brand guidelines...`, 'system');

          // Clear the flags after use
          sessionStorage.removeItem('brandExtensionMode');
          sessionStorage.removeItem('brandExtensionPrompt');

        } else {
          // === NORMAL CLONE MODE ===
          // Check if we have pre-scraped markdown content from search results
          const storedMarkdown = sessionStorage.getItem('siteMarkdown');
        if (storedMarkdown) {

View on GitHub (pinned to 69bd93bae7)

Solutions

  1. Read brandGuidelines.error from the response — the thrown message contains it
  2. Verify the URL serves a real, publicly accessible HTML page with standard CSS (test with curl/view-source)
  3. Try a different page on the same brand site (e.g. the homepage) that has richer styling
  4. Retry once in case the target site served a transient error page
  5. If the site is a client-rendered SPA, use a URL known to include static styles or fall back to manual brand input

Example fix

// before
if (!brandGuidelines.success) {
  throw new Error(brandGuidelines.error || 'Failed to extract brand styles');
}
// after
if (!brandGuidelines?.success || !brandGuidelines?.guidelines) {
  throw new Error(brandGuidelines?.error || 'Extraction returned no usable brand guidelines');
}
Defensive patterns

Strategy: type-guard

Validate before calling

const data = await extractResponse.json();
if (typeof data !== 'object' || data === null || data.success !== true || !data.guidelines) {
  throw new Error(data?.error || 'Extraction returned no usable brand guidelines');
}

Type guard

function isBrandSuccess(d: unknown): d is { success: true; guidelines: Record<string, unknown>; error?: undefined } {
  return typeof d === 'object' && d !== null &&
    (d as any).success === true && typeof (d as any).guidelines === 'object' && (d as any).guidelines !== null;
}

Try / catch

try {
  const data = await extractResponse.json();
  if (!isBrandSuccess(data)) throw new Error(data?.error || 'Failed to extract brand styles');
  brandGuidelines = data;
} catch (err: any) {
  addChatMessage(`Branding failed: ${err.message}`, 'system');
  // fall back to manual brand settings input
}

Prevention

When it happens

Trigger: extractResponse.json() yields { success: false, error: '...' }: the extractor fetched the page but found no styles/colors/typography it could parse, the page returned a soft error page (200 with 'not found' HTML), or server-side parsing threw and was converted into a success:false payload.

Common situations: Target site is a JS-only SPA whose styles are not in the initial HTML; site uses minimal/unparseable CSS; URL points to a 404/soft-404 page that still returns 200; extractor's CSS parser fails on modern syntax (nested CSS, container queries); site content changed and the extraction heuristics no longer match.

Related errors


AI-assisted analysis of firecrawl/open-lovable@69bd93bae7 (2026-08-28). Data as JSON: /api/errors/00bf4435ff6d3316. Report an issue: GitHub.