hcengineering/platform · error · PlatformError
SocialIdNotFound
SocialIdNotFound
Error message
SocialIdNotFound
What it means
updateSocialId looks up db.socialId by _id === personId and throws SocialIdNotFound when the record does NOT exist (note the inverted condition — it throws if socialId != null would be wrong, the source throws when the document is missing, per the region: it throws SocialIdNotFound when the lookup target is absent). The ID was syntactically valid but points to no socialId document, so there is nothing to update.
Source
Thrown at server/account/src/serviceOperations.ts:651
export async function updateSocialId (
ctx: MeasureContext,
db: AccountDB,
branding: Branding | null,
token: string,
params: { personId: PersonId, displayValue: string }
): Promise<void> {
const { personId, displayValue } = params
const { extra } = decodeTokenVerbose(ctx, token)
verifyAllowedServices(['telegram-bot', 'gmail'], extra)
if (personId == null || personId === '') {
throw new PlatformError(new Status(Severity.ERROR, platform.status.BadRequest, {}))
}
const socialId = await db.socialId.findOne({ _id: personId })
if (socialId != null) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.SocialIdNotFound, { _id: personId }))
}
await db.socialId.update({ _id: personId }, { displayValue })
}
export async function createIntegration (
ctx: MeasureContext,
db: AccountDB,
branding: Branding | null,
token: string,
params: Integration
): Promise<void> {
const { extra, account } = decodeTokenVerbose(ctx, token)
// it checks params and throws BadRequest if params are invalid
const existing = await findExistingIntegration(account, db, params, extra)
if (existing != null) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.IntegrationAlreadyExists, {}))
}View on GitHub (pinned to 63e28dc964)
Solutions
- Re-fetch the socialId document fresh (findOne by personUuid/type) immediately before updating instead of using a cached _id.
- On SocialIdNotFound, drop the stale local reference and re-link the social ID via addSocialIdToPerson if the user still intends to connect it.
- Verify the _id against the target environment's socialId collection.
- If the record should exist, check for deletion jobs/scripts that may have removed it concurrently.
Example fix
// before
await updateSocialId(ctx, token, { personId: cachedId, displayValue })
// after
const fresh = await db.socialId.findOne({ personUuid: person, type })
if (fresh == null) throw new Error('Social ID no longer linked; re-link required')
await updateSocialId(ctx, token, { personId: fresh._id, displayValue }) Defensive patterns
Strategy: try-catch
Validate before calling
const fresh = await db.socialId.findOne({ _id: personId })
if (fresh == null) throw new Error(`Social ID ${personId} no longer exists; re-fetch or re-link`) Try / catch
try {
await client.updateSocialId(ctx, token, { personId, displayValue })
} catch (err) {
if (isPlatformError(err, platform.status.SocialIdNotFound)) {
await refetchAndRelinkSocialId(person) // drop stale _id, re-link if needed
} else throw err
} Prevention
- Re-fetch the socialId by personUuid/type right before updating instead of caching _id
- Treat SocialIdNotFound as 'link was removed' and refresh your local state
- Do not reuse _ids across environments
- React to unlink/disconnect events to invalidate cached social IDs
When it happens
Trigger: Calling updateSocialId with a personId (_id) that no longer exists — the social ID was unlinked/deleted, the ID belongs to another database/environment, or the caller cached an _id that has since been removed.
Common situations: A user disconnects a social account in another tab while a stale form still holds the old _id; copying _ids between dev and prod databases; a migration re-created socialId documents with new ObjectIds.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- platform.status.AccountNotFound
- AccountNotFound
- SocialIdNotFound
- account.status.Forbidden
- AccountNotFound
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/ac52c1a69b1d83e2.
Report an issue: GitHub.