{"record":{"id":"a99949b3a3756b42","repo":"musistudio/claude-code-router","slug":"provider-account-credential-was-not-found","errorCode":null,"errorMessage":"Provider account credential was not found.","messagePattern":"Provider account credential was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/providers/account-service.ts","lineNumber":489,"sourceCode":"  return providerAccount && providerApiKey(provider) ? [{ account: providerAccount, provider }] : [];\n}\n\nfunction codexResetProvider(config: AppConfig, providerName: string, credentialId: string | undefined): GatewayProviderConfig {\n  const normalizedProviderName = normalizeProviderName(providerName);\n  const provider = config.Providers.find((candidate) =>\n    isGatewayProviderEnabled(candidate) &&\n    normalizeProviderName(candidate.name) === normalizedProviderName\n  );\n  if (!provider) {\n    throw new Error(\"Provider account was not found.\");\n  }\n\n  const target = providerAccountTargets(provider).find((candidate) => {\n    const candidateCredentialId = candidate.credential ? providerCredentialRuntimeId(candidate.provider, candidate.credential) : undefined;\n    return !credentialId || candidateCredentialId === credentialId;\n  });\n  if (!target) {\n    throw new Error(\"Provider account credential was not found.\");\n  }\n  if (!providerAccountHasCodexResetCreditsConnector(target.account)) {\n    throw new Error(\"Provider account does not support Codex manual reset credits.\");\n  }\n\n  return target.credential\n    ? providerWithCredentialApiKey(target.provider, target.credential, target.account)\n    : { ...target.provider, account: target.account };\n}\n\nfunction providerAccountHasCodexResetCreditsConnector(account: ProviderAccountConfig): boolean {\n  return normalizeConnectors(account).some((connector) =>\n    connector.type === \"http-json\" &&\n    /\\/wham\\/rate-limit-reset-credits(?:$|[?#/])/i.test(connector.endpoint.trim())\n  );\n}\n\nfunction providerAccountUnavailableSnapshots(provider: GatewayProviderConfig): ProviderAccountSnapshot[] {","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/providers/account-service.ts#L471-L507","documentation":"Thrown by codexResetProvider when no provider account target matches the given credential. The service searches providerAccountTargets(provider) for an account whose credential runtime ID equals the requested credentialId (or any account when credentialId is empty); if none matches, this error is raised.","triggerScenarios":"Calling codexResetProvider(provider, credentialId) where credentialId does not match any configured account credential, or where the provider has no account targets at all.","commonSituations":"Credential was removed or rotated after the caller captured its ID; stale credential reference in stored config; provider imported without any account connector.","solutions":["Verify the credentialId exists in the provider's accounts config before calling","Re-import or re-authenticate the provider account to regenerate credentials","Pass an empty credentialId to select the first matching target"],"exampleFix":"// before\nawait codexResetProvider(provider, staleCredentialId);\n// after\nconst target = providerAccountTargets(provider).find(t => !credentialId || providerCredentialRuntimeId(t.provider, t.credential) === credentialId);\nif (!target) throw new Error('credential missing — re-authenticate');\nawait codexResetProvider(provider, credentialId);","handlingStrategy":"validation","validationCode":"const targets = providerAccountTargets(provider);\nconst ok = !credentialId || targets.some(t => t.credential && providerCredentialRuntimeId(t.provider, t.credential) === credentialId);\nif (!ok) throw new Error('re-authenticate provider before reset');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message.includes('credential was not found')) await reauthAndReimportProvider(); else throw e; }","preventionTips":["Persist credential runtime IDs alongside credentials","Re-validate credential references after config edits"],"tags":["provider","credentials","codex"],"backgroundTag":"credential-not-found","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}