can1357/oh-my-pi · error · Error
Failed to create Smithery auth session: ${response.status} $
Error message
Failed to create Smithery auth session: ${response.status} ${response.statusText} What it means
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.
Source
Thrown at packages/coding-agent/src/mcp/smithery-auth.ts:47
}
function normalizeApiKey(value: string | undefined): string | undefined {
if (!value) return undefined;
const trimmed = value.trim();
return trimmed.length > 0 ? trimmed : undefined;
}
export function getSmitheryLoginUrl(): string {
return SMITHERY_URL;
}
export async function createSmitheryCliAuthSession(): Promise<SmitheryCliAuthSession> {
const response = await fetch(`${SMITHERY_URL}/api/auth/cli/session`, {
method: "POST",
signal: withTimeoutSignal(SMITHERY_AUTH_TIMEOUT_MS),
});
if (!response.ok) {
throw new Error(`Failed to create Smithery auth session: ${response.status} ${response.statusText}`);
}
return (await response.json()) as SmitheryCliAuthSession;
}
export async function pollSmitheryCliAuthSession(
sessionId: string,
signal?: AbortSignal,
): Promise<SmitheryCliPollResponse> {
const response = await fetch(`${SMITHERY_URL}/api/auth/cli/poll/${sessionId}`, {
signal: withTimeoutSignal(SMITHERY_POLL_TIMEOUT_MS, signal),
});
if (!response.ok) {
if (response.status === 404 || response.status === 410) {
throw new Error("Smithery login session expired. Please try again.");
}
throw new Error(`Smithery auth polling failed: ${response.status} ${response.statusText}`);
}
return (await response.json()) as SmitheryCliPollResponse;View on GitHub (pinned to 9690622007)
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
Example fix
// before: only interactive login
await createSmitheryCliAuthSession();
// after: fall back to manual API key entry on failure
try {
await createSmitheryCliAuthSession();
} catch (e) {
const key = await promptUserForApiKey(); // from Smithery dashboard
await saveSmitheryApiKey(key);
} Defensive patterns
Strategy: try-catch
Validate before calling
// preflight reachability check
const reachable = await fetch("https://smithery.ai", { method: "HEAD", signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);
if (!reachable) console.warn("Smithery unreachable — use manual API key entry"); Try / catch
try {
const session = await createSmitheryCliAuthSession();
} catch (err) {
logger.warn("Smithery session creation failed, offering manual API key", { err });
const apiKey = await promptForApiKey(); // manual fallback
await saveSmitheryApiKey(apiKey);
} Prevention
- 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
When it happens
Trigger: Calling createSmitheryCliAuthSession when Smithery's auth server responds with 4xx/5xx — server outage, rate limiting, or blocked network/proxy.
Common situations: Corporate proxy or firewall blocking api.smithery.ai, Smithery service outage/maintenance, rate limiting after repeated login attempts.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Smithery auth polling failed: ${response.status} ${response.
- Perplexity ask API error (${response.status}): ${errorText}
- V2 remote compaction failed (${response.status} ${response.s
- Bedrock HTTP ${response.status}: ${errBody.slice(0, 1000)}
- sso-role
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/1a9374f97fef2b30.
Report an issue: GitHub.