{"record":{"id":"e3ffc030280f1f52","repo":"coleam00/Archon","slug":"github-account-login-is-already-linked-to-a-di","errorCode":null,"errorMessage":"GitHub account @${login} is already linked to a different Archon user.","messagePattern":"GitHub account @(.+?) is already linked to a different Archon user\\.","errorType":"exception","errorClass":"GithubIdentityConflictError","httpStatus":null,"severity":"error","filePath":"packages/core/src/db/users.ts","lineNumber":260,"sourceCode":"           updated_at = ${dialect.now()}\n     WHERE id = $3`,\n    [profile.display_name ?? null, profile.email ?? null, userId]\n  );\n}\n\n/**\n * Attach a GitHub identity to an EXISTING Archon user (the connecting actor).\n * Unlike findOrCreateUserByPlatformIdentity, this never mints a new user — the\n * device-flow connect surfaces already have the actor's user_id and only need\n * to bind their GitHub login to it. Throws GithubIdentityConflictError if the\n * login already maps to a different user.\n */\nexport async function linkGithubIdentity(userId: string, login: string): Promise<void> {\n  const platform: IdentityPlatform = 'github';\n  const existing = await selectIdentity(platform, login);\n  if (existing) {\n    if (existing.user_id !== userId) {\n      throw new GithubIdentityConflictError(login);\n    }\n    await pool.query(\n      'UPDATE remote_agent_user_identities SET platform_display_name = $1 WHERE id = $2',\n      [login, existing.id]\n    );\n    getLog().info({ userId, login }, 'user.github_identity_relinked');\n    return;\n  }\n  try {\n    await pool.query(\n      `INSERT INTO remote_agent_user_identities (user_id, platform, platform_user_id, platform_display_name)\n       VALUES ($1, $2, $3, $4)`,\n      [userId, platform, login, login]\n    );\n    getLog().info({ userId, login }, 'user.github_identity_linked');\n  } catch (err) {\n    // Concurrent connect of the same ('github', login) raced us past the SELECT\n    // and inserted first. UNIQUE(platform, platform_user_id) rejects the loser —","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/users.ts#L242-L278","documentation":"Error \"GitHub account @${login} is already linked to a different Archon user.\" thrown in coleam00/Archon.","triggerScenarios":"Thrown at packages/core/src/db/users.ts:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}