hcengineering/platform · error · Error

sequence object not found

Error message

sequence object not found

What it means

Thrown in CreateVacancy.svelte when the Sequence object for recruit.class.Vacancy is missing. The vacancy number is generated by incrementing this sequence, so creation aborts if the sequence document cannot be found.

Source

Thrown at plugins/recruit-resources/src/components/CreateVacancy.svelte:231

      for (const label of tagElements) {
        await client.addCollection(tags.class.TagReference, space, resId, tracker.class.Issue, 'labels', {
          title: label.title,
          color: label.color,
          tag: label._id
        })
      }
    }
    return resId
  }

  async function createVacancy (): Promise<void> {
    if (typeId === undefined || typeType === undefined) {
      throw Error(`Failed to find target project type: ${typeId}`)
    }

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

    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
    const data: Data<Vacancy> = {
      ...vacancyData,
      name: name.trim(),
      description: template?.shortDescription ?? '',
      fullDescription: null,
      private: false,
      archived: false,
      number: (incResult as any).object.sequence,
      company,
      members,
      autoJoin: typeType.autoJoin ?? false,
      owners: [getCurrentAccount().uuid],
      type: typeId
    }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Run plugin migrations/seed to create the Vacancy sequence object
  2. Create the sequence manually (core.class.Sequence with attachedTo: recruit.class.Vacancy, sequence: 0)
  3. Check for the sequence document before opening the create dialog
  4. Catch the error, seed the sequence, and retry the creation

Example fix

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

Strategy: validation

Validate before calling

const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy })
if (sequence === undefined) {
  await ensureSequence(recruit.class.Vacancy, 0)
}

Type guard

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

Try / catch

try {
  await createVacancy()
} catch (err) {
  if (err instanceof Error && err.message === 'sequence object not found') {
    await seedSequences()
    return createVacancy()
  }
  throw err
}

Prevention

When it happens

Trigger: client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy }) returns undefined because the sequence was never seeded, deleted, or migrations have not been applied to the workspace.

Common situations: Fresh workspace or upgrade where vacancy sequence seeding was skipped; cleanup job removed sequence docs; restored data missing system documents.

Related errors


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