{"record":{"id":"a927a38258201d17","repo":"firecrawl/open-lovable","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/generation/page.tsx","lineNumber":605,"sourceCode":"        console.log('[createSandbox] Sandbox ready with Vite server running');\n        \n        // Only add welcome message if not coming from home screen\n        if (!fromHomeScreen) {\n          addChatMessage(`Sandbox created! ID: ${data.sandboxId}. I now have context of your sandbox and can help you build your app. Just ask me to create components and I'll automatically apply them!\n\nTip: I automatically detect and install npm packages from your code imports (like react-router-dom, axios, etc.)`, 'system');\n        }\n        \n        setTimeout(() => {\n          if (iframeRef.current) {\n            iframeRef.current.src = data.url;\n          }\n        }, 100);\n        \n        // Return the sandbox data so it can be used immediately\n        return data;\n      } else {\n        throw new Error(data.error || 'Unknown error');\n      }\n    } catch (error: any) {\n      console.error('[createSandbox] Error:', error);\n      updateStatus('Error', false);\n      log(`Failed to create sandbox: ${error.message}`, 'error');\n      addChatMessage(`Failed to create sandbox: ${error.message}`, 'system');\n      throw error;\n    } finally {\n      setLoading(false);\n      sandboxCreationRef.current = false; // Reset the ref\n    }\n  };\n\n  const displayStructure = (structure: any) => {\n    if (typeof structure === 'object') {\n      setStructureContent(JSON.stringify(structure, null, 2));\n    } else {\n      setStructureContent(structure || 'No structure available');","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/firecrawl/open-lovable/blob/69bd93bae7a9c97ef989eb70aabe6797fb3dac89/app/generation/page.tsx#L587-L623","documentation":"createSandbox() in app/generation/page.tsx throws this Error when the sandbox-creation API responds with ok:false and no `error` field, falling back to 'Unknown error'. It is the client-side catch-all for failed sandbox provisioning whose server response lacks a message.","triggerScenarios":"POST to the sandbox API returns ok:false with an absent/empty error string — server crashed before setting error, proxy/gateway returned an unexpected payload, auth rejected the request with a bare body, or JSON shape changed between client and API.","commonSituations":"Vercel function returning 500 without a JSON body; expired auth token; provider (E2B/Vercel) API outage server-side; API route updated its response contract while the page expects data.error.","solutions":["Log the full response (status + body) in the API route to expose the real failure","Ensure the server route always includes an `error` message in failure payloads","Check that Vercel/E2B credentials and upstream sandbox APIs are reachable/valid","Retry creation on transient failures and surface the true status code in the chat error message"],"exampleFix":"// before\nthrow new Error(data.error || 'Unknown error');\n// after\nconst detail = data.error || `status ${response.status}: ${await response.text().catch(() => 'no body')}`;\nthrow new Error(detail);","handlingStrategy":"try-catch","validationCode":"const res = await fetch('/api/sandbox', { method: 'POST' });\nconst payload = await res.json();\nif (!res.ok || !payload?.ok) throw new Error(`Sandbox API failed: ${res.status} ${payload?.error ?? 'no detail'}`);","typeGuard":"function isSandboxData(v: unknown): v is { sandboxId: string; url: string } { return !!v && typeof v === 'object' && typeof (v as any).sandboxId === 'string'; }","tryCatchPattern":"try {\n  const data = await createSandbox();\n} catch (error) {\n  updateStatus('Error', false);\n  log(`Failed to create sandbox: ${error.message}`, 'error');\n  addChatMessage(`Failed to create sandbox: ${error.message}`, 'system');\n  throw error;\n}","preventionTips":["Always return a JSON error message from the sandbox API route","Log response status and body client-side before falling back to 'Unknown error'","Retry creation once on transient 5xx/gateway failures","Validate API response shape when upgrading either side of the contract"],"tags":["api","sandbox","network","error-handling"],"backgroundTag":"unknown-error-fallback","analyzedSha":"69bd93bae7a9c97ef989eb70aabe6797fb3dac89","analyzedAt":"2026-08-28T22:20:32.339Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}