{"record":{"id":"efa88a68a173f9e6","repo":"bytedance/deer-flow","slug":"setup-status-failed-response-status","errorCode":null,"errorMessage":"setup-status failed: ${response.status}","messagePattern":"setup-status failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"frontend/src/core/auth/setup.ts","lineNumber":29,"sourceCode":"  status: SetupStatusResponse | null;\n};\n\nexport const setupStatusFetchInit = {\n  cache: \"no-store\",\n  credentials: \"include\",\n} satisfies RequestInit;\n\nexport async function fetchSetupStatus(): Promise<SetupStatusResponse> {\n  const controller = new AbortController();\n  const timeout = setTimeout(() => controller.abort(), AUTH_REQUEST_TIMEOUT_MS);\n\n  try {\n    const response = await fetch(\"/api/v1/auth/setup-status\", {\n      ...setupStatusFetchInit,\n      signal: controller.signal,\n    });\n    if (!response.ok) {\n      throw new Error(`setup-status failed: ${response.status}`);\n    }\n    return (await response.json()) as SetupStatusResponse;\n  } finally {\n    clearTimeout(timeout);\n  }\n}\n\nexport function isSystemAlreadyInitializedError(data: unknown): boolean {\n  return parseAuthError(data).code === \"system_already_initialized\";\n}\n\nexport function canCreateRegularAccount(check: SetupStatusCheck): boolean {\n  // registration_enabled is absent on older Gateways; treat that as allowed so\n  // the signup entry only disappears when the backend actively closes it.\n  return (\n    check.checked &&\n    check.status?.needs_setup !== true &&\n    check.status?.registration_enabled !== false","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/frontend/src/core/auth/setup.ts#L11-L47","documentation":"Thrown when GET /api/v1/auth/setup-status returns non-2xx. This unauthenticated probe (with AbortController timeout AUTH_REQUEST_TIMEOUT_MS) tells the login page whether initial system initialization is needed. Non-2xx means the auth router is absent/misrouted (404) or the Gateway is failing before auth runs (5xx). Note the fetch uses a relative path, so it depends on same-origin routing via nginx.","triggerScenarios":"Accessing the frontend directly on :3000 in a deployment where only the nginx entry :2026 routes /api to the Gateway; Gateway restarting (502); backend built without the auth v1 router; a timeout abort (fetch rejects with AbortError before this check, but slow 5xx also lands here).","commonSituations":"Dev workflow pointing the browser at the Next.js port instead of the nginx port; upgrading the backend across an auth API version change; corporate proxy intercepting /api/v1/*.","solutions":["Open the app through the nginx entry point (default http://localhost:2026), not :3000 directly","curl http://localhost:2026/api/v1/auth/setup-status to see the raw status returned by the proxy chain","Wait for /health on the Gateway to be green, then reload the page","If 404 persists, confirm the deployed backend version includes the /api/v1/auth routes"],"exampleFix":"// before\nconst status = await fetchSetupStatus();\n\n// after\nconst status = await fetchSetupStatus().catch((e) => {\n  if (e instanceof Error && e.message.startsWith('setup-status failed: 502')) {\n    return retryAfterGatewayHealthy();\n  }\n  throw e;\n});","handlingStrategy":"retry","validationCode":null,"typeGuard":"export function isSetupStatusError(e: unknown): e is Error {\n  return e instanceof Error && e.message.startsWith('setup-status failed:');\n}","tryCatchPattern":"try {\n  return await fetchSetupStatus();\n} catch (e) {\n  if (isSetupStatusError(e) && (e.message.endsWith('502') || e.message.endsWith('503'))) {\n    return await waitForGatewayThenRetry(); // bounded retries\n  }\n  throw e;\n}","preventionTips":["Always enter via the nginx port (2026), not the Next.js port, so relative /api resolves","Sequence auth page load after /health returns ok","Keep AUTH_REQUEST_TIMEOUT_MS generous for slow cold starts"],"tags":["auth","setup","http","routing","frontend"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}