{"record":{"id":"5734ee7ca2214cf9","repo":"diegosouzapw/OmniRoute","slug":"duplicate-account","errorCode":"duplicate_account","errorMessage":"An Antigravity CLI connection for this account already exists. Pass overwriteExisting: true to replace it.","messagePattern":"An Antigravity CLI connection for this account already exists\\. Pass overwriteExisting: true to replace it\\.","errorType":"exception","errorClass":"AgyAuthFileError","httpStatus":409,"severity":"error","filePath":"src/lib/oauth/utils/agyAuthImport.ts","lineNumber":199,"sourceCode":"      const conn = c as JsonRecord;\n      return toNonEmptyString(conn.email)?.toLowerCase() === lowerEmail;\n    }) as JsonRecord | undefined) ?? null\n  );\n}\n\n// ──── Create / update connection ──────────────────────────────────────────────\n\nexport async function createConnectionFromAgyToken(\n  enriched: EnrichedAgyAuth,\n  options: CreateAgyConnectionOptions\n): Promise<{ connection: JsonRecord; created: boolean }> {\n  const resolvedEmail = options.email || enriched.email;\n\n  if (resolvedEmail) {\n    const existing = await findExistingAgyConnection(resolvedEmail);\n    if (existing) {\n      if (!options.overwriteExisting) {\n        throw new AgyAuthFileError(\n          \"An Antigravity CLI connection for this account already exists. Pass overwriteExisting: true to replace it.\",\n          409,\n          \"duplicate_account\"\n        );\n      }\n\n      const updated = await updateProviderConnection(existing.id as string, {\n        accessToken: enriched.accessToken,\n        refreshToken: enriched.refreshToken,\n        expiresAt: enriched.expiresAt,\n        email: resolvedEmail || (existing.email as string | undefined),\n        name:\n          options.name ||\n          (existing.name as string | undefined) ||\n          resolvedEmail ||\n          \"Antigravity CLI (imported)\",\n        testStatus: \"active\",\n        isActive: true,","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/utils/agyAuthImport.ts#L181-L217","documentation":"Duplicate guard in createConnectionFromAgyToken: an existing Antigravity CLI connection with the same (lowercased) email was found, and options did not include overwriteExisting: true. The import refuses to silently replace an existing connection for that account.","triggerScenarios":"Thrown at src/lib/oauth/utils/agyAuthImport.ts:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass overwriteExisting: true to replace the existing connection for that account","Or delete/rename the existing connection before importing","Surface a UI choice (replace vs cancel) instead of a hard failure"],"exampleFix":null,"handlingStrategy":"validation","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"}