hcengineering/platform · error · Error

sequence object not found

Error message

sequence object not found

What it means

CreateReview.svelte looks up the core Sequence object attached to `recruit.class.Review` to assign a sequential number to the new review. If no such Sequence document exists, the numbering cannot proceed and it throws 'sequence object not found'. Sequences are seeded per numbered class during workspace setup/upgrade.

Source

Thrown at plugins/recruit-resources/src/components/review/CreateReview.svelte:92

    title,
    participants: [currentUser],
    eventId: '',
    dueDate: 0,
    calendar: '' as Ref<Calendar>
  }

  const dispatch = createEventDispatcher()
  const client = getClient()
  const hierarchy = client.getHierarchy()

  export function canClose (): boolean {
    return (preserveCandidate || candidate === undefined) && title.length === 0
  }

  async function createReview () {
    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })
    if (sequence === undefined) {
      throw new Error('sequence object not found')
    }

    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)

    const candidateInstance = await client.findOne(contact.class.Person, { _id: doc.attachedTo as Ref<Person> })
    if (candidateInstance === undefined) {
      throw new Error('contact not found')
    }
    if (!client.getHierarchy().hasMixin(candidateInstance, recruit.mixin.Candidate)) {
      await client.createMixin<Person, Candidate>(
        candidateInstance._id,
        candidateInstance._class,
        candidateInstance.space,
        recruit.mixin.Candidate,
        {}
      )
    }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Seed the missing Sequence object for recruit.class.Review via the generateSequence/setup routine.
  2. Run the platform upgrade/migration that generates sequences for all classes with numbering patterns.
  3. Create the sequence lazily in code when findOne returns undefined instead of throwing.
  4. Audit the model space for Sequence docs attachedTo Review and re-create missing ones.

Example fix

// before
const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })
if (sequence === undefined) {
  throw new Error('sequence object not found')
}
// after
let sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })
if (sequence === undefined) {
  sequence = await client.createDoc(core.class.Sequence, core.space.Model, {
    attachedTo: recruit.class.Review,
    sequence: 0
  })
}
Defensive patterns

Strategy: try-catch

Validate before calling

const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })
if (sequence === undefined) {
  await client.createDoc(core.class.Sequence, core.space.Model, { attachedTo: recruit.class.Review, sequence: 0 })
}

Type guard

function hasSequence(s: Sequence | undefined): s is Sequence { return s !== undefined }

Try / catch

try {
  await createReview()
} catch (e) {
  if (e.message === 'sequence object not found') {
    await seedSequence(recruit.class.Review)
    await createReview()
  } else throw e
}

Prevention

When it happens

Trigger: Calling createReview when `client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })` returns undefined — no sequence was seeded for the Review class in this workspace.

Common situations: Workspace created before sequence seeding ran, backup restore missing model-space sequence docs, manual deletion during cleanup, plugin version upgrade that re-created class ids without migrating sequences.

Related errors


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