hcengineering/platform · error
Confirmed social identity is attached to the wrong person
Error message
Confirmed social identity is attached to the wrong person
What it means
ensureEmployeeForPerson validates that a confirmed (verifiedOn set) social identity is not attached to a different person than the one being processed. Unconfirmed identities may move between persons (merge scenarios), but confirmed ones must not, so the function throws to protect data integrity until an accounts-merge feature exists.
Source
Thrown at plugins/contact/src/utils.ts:528
attachedToClass: contact.class.Person,
collection: 'socialIds',
type: socialId.type,
value: socialId.value,
key: buildSocialIdString(socialId), // TODO: fill it in trigger or on DB level as stored calculated column or smth?
verifiedOn: socialId.verifiedOn,
isDeleted: socialId.isDeleted ?? false
},
socialId._id as SocialIdentityRef
)
)
await client.tx(createSocialIdTx)
})
} else {
// If not confirmed locally can be attached to a different person (persons merge scenario)
// Confirmed social identity should not be attached to a different person for now
// It will change with accounts merge function
if (existing.verifiedOn != null && existing.attachedTo !== personRef) {
throw new Error('Confirmed social identity is attached to the wrong person')
}
// Check and update if needed. It can:
// 1. Become verified (maybe with persons merge) (changes verifiedOn, attachedTo)
const sidUpdate: DocumentUpdate<SocialIdentity> = {}
let needUpdate = false
// become verified
if (existing.verifiedOn == null) {
sidUpdate.verifiedOn = socialId.verifiedOn
needUpdate = true
}
// merged from another person
if (existing.attachedTo !== personRef) {
sidUpdate.attachedTo = personRef
// Bump collection in Person?
needUpdate = trueView on GitHub (pinned to 63e28dc964)
Solutions
- Verify the correct person owns the confirmed identity; unmerge or detach the identity from the wrong person first
- Reset verifiedOn (unconfirm) the identity if it genuinely needs reassignment, then re-verify under the right person
- Skip or reconcile the conflicting person before running the merge
- Fix upstream merge logic so identities are re-pointed before ensureEmployee runs
Example fix
// before
await ensureEmployee(client, personA) // identity.verifiedOn set, attachedTo = personB
// after
await client.update(identity, { attachedTo: personA, verifiedOn: Date.now() })
await ensureEmployee(client, personA) Defensive patterns
Strategy: validation
Validate before calling
const existing = identities.find(i => i.key === sid)
if (existing?.verifiedOn != null && existing.attachedTo !== person._id) {
// reconcile identity ownership before calling ensureEmployee
} Type guard
function isSafeToAttach(identity: SocialIdentity | undefined, personRef: Ref<Person>): boolean {
return identity === undefined || identity.verifiedOn == null || identity.attachedTo === personRef
} Try / catch
try {
await ensureEmployee(client, person)
} catch (err) {
if (err.message.includes('Confirmed social identity is attached to the wrong person')) {
// resolve identity ownership conflict manually / via admin tooling
}
throw err
} Prevention
- Before merging persons, re-point or unconfirm conflicting verified identities
- Audit social identities for verifiedOn/attachedTo consistency before bulk merges
- Sequence merge operations to avoid concurrent identity reassignment
- Document that verified identities cannot be silently moved between persons
When it happens
Trigger: Merging or re-attributing persons where a SocialIdentity has verifiedOn set and attachedTo pointing at a different personRef than the target person; calling ensureEmployee for a person whose identity record belongs to someone else.
Common situations: Duplicate-person cleanup scripts merging two employees who shared a verified social login; import/migration tooling re-linking identities; concurrent person-merge operations racing.
Related errors
- Parent not found: ${issue.clickupParentId} (for task: ${clic
- Project not found: ${issue.clickupProjectName} (for task: ${
- Task cannot be imported: ${clickupId} (No parent)
- Social ID not found for email: ${email}
- Email is not defined in integration
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/75b1d69950aa14ac.
Report an issue: GitHub.