{"record":{"id":"3305d3f5f6d86d5f","repo":"can1357/oh-my-pi","slug":"no-authentication-method-available","errorCode":null,"errorMessage":"No authentication method available.","messagePattern":"No authentication method available\\.","errorType":"exception","errorClass":"SearchProviderError","httpStatus":401,"severity":"error","filePath":"packages/coding-agent/src/web/search/providers/perplexity.ts","lineNumber":962,"sourceCode":"\t\t\t\t\t{\n\t\t\t\t\t\tprovider: \"perplexity\",\n\t\t\t\t\t\tanswer: askResult.answer || undefined,\n\t\t\t\t\t\tsources: askResult.sources,\n\t\t\t\t\t\tmodel: askResult.model,\n\t\t\t\t\t\trequestId: askResult.requestId,\n\t\t\t\t\t\tauthMode: auth.type === \"anonymous\" ? \"anonymous\" : \"oauth\",\n\t\t\t\t\t},\n\t\t\t\t\tparams.num_results,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (params.signal?.aborted) throw error;\n\t\t\t\tlastError = error;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lastError) throw lastError;\n\tthrow new SearchProviderError(\"perplexity\", \"No authentication method available.\", 401);\n}\n\n/** Search provider for Perplexity. */\nexport class PerplexityProvider extends SearchProvider {\n\treadonly id = \"perplexity\";\n\treadonly label = \"Perplexity\";\n\n\t/**\n\t * Auto-chain admission. Requires a direct Perplexity credential\n\t * (`PERPLEXITY_COOKIES`, OAuth session, or `PERPLEXITY_API_KEY`).\n\t *\n\t * OpenRouter auth is intentionally NOT accepted here: silently using\n\t * OpenRouter's `perplexity/sonar-pro` whenever any OpenRouter key is\n\t * configured surprises users (and bills them) for a path they never\n\t * asked for. The auto chain skips Perplexity in that case and falls\n\t * through to the next configured provider. Users who DO want the\n\t * OpenRouter-backed Perplexity path can still opt in by setting\n\t * `webSearch: perplexity` explicitly — see {@link isExplicitlyAvailable}.","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/web/search/providers/perplexity.ts#L944-L980","documentation":"After exhausting every available Perplexity authentication method (API key, OAuth, cookies, anonymous), none succeeded and none produced a lastError, so the provider concludes there is no usable auth method at all and throws a SearchProviderError with status 401.","triggerScenarios":"getAvailableAuthMethods returns an empty list (no PERPLEXITY_API_KEY, no stored OAuth session, no cookies, and anonymous access unavailable/disabled) when search attempts to authenticate.","commonSituations":"Fresh install with no Perplexity credentials configured, environment variables not exported in the runtime environment, OAuth session expired and was pruned, running in CI without secrets.","solutions":["Set PERPLEXITY_API_KEY in the environment or settings","Complete Perplexity OAuth login to store a session","Verify the env vars are visible to the process (shell profile, CI secrets)","Fall back to a credential-free provider (e.g. the public aggregate)"],"exampleFix":"// before\nexport PATH=...\n// after\nexport PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxxxxxx","handlingStrategy":"validation","validationCode":"const hasAuth = Boolean(process.env.PERPLEXITY_API_KEY) || hasStoredOAuthSession(\"perplexity\");\nif (!hasAuth) {\n  // configure credentials or route to a credential-free provider\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await perplexitySearch(params);\n} catch (err) {\n  if (err instanceof SearchProviderError && err.statusCode === 401 && err.message.includes(\"No authentication\")) {\n    return publicWebSearch(params); // credential-free fallback\n  }\n  throw err;\n}","preventionTips":["Set PERPLEXITY_API_KEY or complete OAuth login before searching","Verify secrets are present in the runtime environment (CI, containers)","Fall back to credential-free engines when no Perplexity auth exists"],"tags":["auth","perplexity","missing-credentials","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}