hcengineering/platform · critical · PlatformError

platform.status.InternalServerError

platform.status.InternalServerError

Error message

InternalServerError

What it means

During signup when email confirmation is forced, the server re-reads the freshly created person record via `db.person.findOne({ uuid: account })`. If the person document is missing even though the account uuid exists, the server throws InternalServerError because it cannot thread invite info into the confirmation email. This indicates an inconsistent account/person state rather than a client mistake.

Source

Thrown at server/account/src/operations.ts:1337

  const mailURL = getMetadata(accountPlugin.metadata.MAIL_URL)
  const forceConfirmation = mailURL !== undefined && mailURL !== ''

  const { account, socialId } = await signUpByEmail(
    ctx,
    db,
    branding,
    email,
    password,
    first,
    last ?? '',
    !forceConfirmation
  )
  void setTimezone(ctx, db, account, null, meta)

  if (forceConfirmation) {
    const person = await db.person.findOne({ uuid: account })
    if (person == null) {
      throw new PlatformError(new Status(Severity.ERROR, platform.status.InternalServerError, {}))
    }

    const normalizedEmail = cleanEmail(email)
    // Thread the invite info through the confirmation token so the user
    // is auto-joined to the workspace once they confirm their email.
    await sendEmailConfirmation(ctx, branding, account, normalizedEmail, {
      inviteId,
      workspaceUrl
    })

    return {
      account,
      name: getPersonName(person),
      socialId,
      token: undefined
    }
  }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify the person document exists in db.person for the account uuid; restore/recreate it if missing.
  2. Check whether account creation and person creation run in the same transaction; make person creation atomic with account creation.
  3. If using a read-from-secondary DB config, ensure reads of the new account go to primary (read-your-writes).
  4. Retry the signup request; if it persists, inspect server logs around account creation for failed inserts.

Example fix

// before
const person = await db.person.findOne({ uuid: account })
if (person == null) { throw ... }

// after (retry primary read)
let person = await db.person.findOne({ uuid: account })
if (person == null) person = await primaryDb.person.findOne({ uuid: account })
if (person == null) { throw new PlatformError(new Status(Severity.ERROR, platform.status.PersonNotFound, { person: account })) }
Defensive patterns

Strategy: retry

Try / catch

try { await signUpJoinWorkspace(ctx, params) } catch (err) { if (isStatusError(err, platform.status.InternalServerError)) { await sleep(200); retryOnce(); } else throw err }

Prevention

When it happens

Trigger: signUpJoinWorkspace / signup flow with forceConfirmation=true where the person row for the just-created account uuid is not found (replication lag, failed person creation, or person deleted between account creation and this lookup).

Common situations: Distributed DB (e.g. mongodb replica read from secondary) returns stale data right after account creation; a bug or migration removed person records; multi-region setup with eventual consistency; partially failed transaction during account provisioning.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/34f3203a79bb46c9. Report an issue: GitHub.