{"record":{"id":"457f9376b25fd2f4","repo":"diegosouzapw/OmniRoute","slug":"exclusive-lease-active","errorCode":"exclusive_lease_active","errorMessage":"Reset-credit operations are deferred while an exclusive lease is active.","messagePattern":"Reset-credit operations are deferred while an exclusive lease is active\\.","errorType":"exception","errorClass":"CodexResetCreditError","httpStatus":409,"severity":"error","filePath":"src/lib/usage/codexResetCredits.ts","lineNumber":308,"sourceCode":"\n  const headers: Record<string, string> = {\n    Authorization: `Bearer ${connection.accessToken}`,\n    \"Content-Type\": \"application/json\",\n    Accept: \"application/json\",\n    // Canonical Codex backend identity (UA + originator + version), same\n    // chain as inference — see getCodexUsage.\n    ...getCodexBackendIdentityHeaders(),\n  };\n\n  const workspaceId = getWorkspaceId(connection);\n  if (workspaceId) headers[\"chatgpt-account-id\"] = workspaceId;\n\n  return headers;\n}\n\nasync function loadCodexConnection(connectionId: string): Promise<CodexConnectionLike> {\n  if (await isConnectionUnavailableToAuxiliaryActivity(connectionId)) {\n    throw new CodexResetCreditError(\n      409,\n      \"exclusive_lease_active\",\n      \"Reset-credit operations are deferred while an exclusive lease is active.\"\n    );\n  }\n  const connection = (await getProviderConnectionById(\n    connectionId\n  )) as unknown as CodexConnectionLike | null;\n\n  if (!connection) {\n    throw new CodexResetCreditError(404, \"connection_not_found\", \"Connection not found.\");\n  }\n\n  if (connection.provider !== \"codex\") {\n    throw new CodexResetCreditError(\n      400,\n      \"codex_provider_required\",\n      \"Reset credits can only be redeemed for OpenAI Codex accounts.\"","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/usage/codexResetCredits.ts#L290-L326","documentation":"Concurrency gate in loadCodexConnection: isConnectionUnavailableToAuxiliaryActivity(connectionId) reported the connection is currently leased for an exclusive activity (e.g. an active token refresh/rotation). Reset-credit operations are deferred with 409 exclusive_lease_active so they don't race the lease holder — retrying after the lease releases is the expected path.","triggerScenarios":"Thrown at src/lib/usage/codexResetCredits.ts:308 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after the exclusive lease on the connection completes","Avoid issuing concurrent reset-credit and refresh operations on the same connection"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}