{"record":{"id":"1a9374f97fef2b30","repo":"can1357/oh-my-pi","slug":"failed-to-create-smithery-auth-session-response","errorCode":null,"errorMessage":"Failed to create Smithery auth session: ${response.status} ${response.statusText}","messagePattern":"Failed to create Smithery auth session: (.+?) (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/mcp/smithery-auth.ts","lineNumber":47,"sourceCode":"}\n\nfunction normalizeApiKey(value: string | undefined): string | undefined {\n\tif (!value) return undefined;\n\tconst trimmed = value.trim();\n\treturn trimmed.length > 0 ? trimmed : undefined;\n}\n\nexport function getSmitheryLoginUrl(): string {\n\treturn SMITHERY_URL;\n}\n\nexport async function createSmitheryCliAuthSession(): Promise<SmitheryCliAuthSession> {\n\tconst response = await fetch(`${SMITHERY_URL}/api/auth/cli/session`, {\n\t\tmethod: \"POST\",\n\t\tsignal: withTimeoutSignal(SMITHERY_AUTH_TIMEOUT_MS),\n\t});\n\tif (!response.ok) {\n\t\tthrow new Error(`Failed to create Smithery auth session: ${response.status} ${response.statusText}`);\n\t}\n\treturn (await response.json()) as SmitheryCliAuthSession;\n}\n\nexport async function pollSmitheryCliAuthSession(\n\tsessionId: string,\n\tsignal?: AbortSignal,\n): Promise<SmitheryCliPollResponse> {\n\tconst response = await fetch(`${SMITHERY_URL}/api/auth/cli/poll/${sessionId}`, {\n\t\tsignal: withTimeoutSignal(SMITHERY_POLL_TIMEOUT_MS, signal),\n\t});\n\tif (!response.ok) {\n\t\tif (response.status === 404 || response.status === 410) {\n\t\t\tthrow new Error(\"Smithery login session expired. Please try again.\");\n\t\t}\n\t\tthrow new Error(`Smithery auth polling failed: ${response.status} ${response.statusText}`);\n\t}\n\treturn (await response.json()) as SmitheryCliPollResponse;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/mcp/smithery-auth.ts#L29-L65","documentation":"Thrown by createSmitheryCliAuthSession when the POST to Smithery's `/api/auth/cli/session` endpoint returns a non-OK status. This is the first step of the browser-based Smithery CLI login; without a session the login cannot proceed.","triggerScenarios":"Calling createSmitheryCliAuthSession when Smithery's auth server responds with 4xx/5xx — server outage, rate limiting, or blocked network/proxy.","commonSituations":"Corporate proxy or firewall blocking api.smithery.ai, Smithery service outage/maintenance, rate limiting after repeated login attempts.","solutions":["Check https://status.smithery.ai or retry after a few minutes if it's a 5xx","Verify network access to Smithery (curl the base URL) and check proxy/firewall settings","If 429, wait and retry later — you are being rate limited","Use the manual API key path instead: create a key in the Smithery dashboard and save it directly"],"exampleFix":"// before: only interactive login\nawait createSmitheryCliAuthSession();\n// after: fall back to manual API key entry on failure\ntry {\n  await createSmitheryCliAuthSession();\n} catch (e) {\n  const key = await promptUserForApiKey(); // from Smithery dashboard\n  await saveSmitheryApiKey(key);\n}","handlingStrategy":"try-catch","validationCode":"// preflight reachability check\nconst reachable = await fetch(\"https://smithery.ai\", { method: \"HEAD\", signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);\nif (!reachable) console.warn(\"Smithery unreachable — use manual API key entry\");","typeGuard":null,"tryCatchPattern":"try {\n  const session = await createSmitheryCliAuthSession();\n} catch (err) {\n  logger.warn(\"Smithery session creation failed, offering manual API key\", { err });\n  const apiKey = await promptForApiKey(); // manual fallback\n  await saveSmitheryApiKey(apiKey);\n}","preventionTips":["Verify corporate proxy/firewall allows egress to smithery.ai before running login","Offer the manual dashboard API-key path as a fallback in scripts/CI","Retry with backoff on 5xx before giving up","Don't hammer the endpoint — repeated rapid attempts can trigger rate limits"],"tags":["network","http","smithery","auth"],"backgroundTag":"http-request-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}