{"record":{"id":"4e9d0b857b692766","repo":"hcengineering/platform","slug":"sequence-object-not-found-4e9d0b","errorCode":null,"errorMessage":"sequence object not found","messagePattern":"sequence object not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/recruit-resources/src/components/CreateVacancy.svelte","lineNumber":231,"sourceCode":"      for (const label of tagElements) {\n        await client.addCollection(tags.class.TagReference, space, resId, tracker.class.Issue, 'labels', {\n          title: label.title,\n          color: label.color,\n          tag: label._id\n        })\n      }\n    }\n    return resId\n  }\n\n  async function createVacancy (): Promise<void> {\n    if (typeId === undefined || typeType === undefined) {\n      throw Error(`Failed to find target project type: ${typeId}`)\n    }\n\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy })\n    if (sequence === undefined) {\n      throw new Error('sequence object not found')\n    }\n\n    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)\n    const data: Data<Vacancy> = {\n      ...vacancyData,\n      name: name.trim(),\n      description: template?.shortDescription ?? '',\n      fullDescription: null,\n      private: false,\n      archived: false,\n      number: (incResult as any).object.sequence,\n      company,\n      members,\n      autoJoin: typeType.autoJoin ?? false,\n      owners: [getCurrentAccount().uuid],\n      type: typeId\n    }\n","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/CreateVacancy.svelte#L213-L249","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh workspace or upgrade where vacancy sequence seeding was skipped; cleanup job removed sequence docs; restored data missing system documents.","solutions":["Run plugin migrations/seed to create the Vacancy sequence object","Create the sequence manually (core.class.Sequence with attachedTo: recruit.class.Vacancy, sequence: 0)","Check for the sequence document before opening the create dialog","Catch the error, seed the sequence, and retry the creation"],"exampleFix":"// before\nconst sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy })\nif (sequence === undefined) {\n  throw new Error('sequence object not found')\n}\n// after\nlet sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy })\nif (sequence === undefined) {\n  sequence = await client.createDoc(core.class.Sequence, core.space.Model, {\n    attachedTo: recruit.class.Vacancy, sequence: 0\n  })\n}","handlingStrategy":"validation","validationCode":"const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Vacancy })\nif (sequence === undefined) {\n  await ensureSequence(recruit.class.Vacancy, 0)\n}","typeGuard":"function hasSequence (s: Sequence | undefined): s is Sequence {\n  return s !== undefined\n}","tryCatchPattern":"try {\n  await createVacancy()\n} catch (err) {\n  if (err instanceof Error && err.message === 'sequence object not found') {\n    await seedSequences()\n    return createVacancy()\n  }\n  throw err\n}","preventionTips":["Seed Vacancy sequences in plugin migration code","Verify system docs after workspace restore","Never purge core.space.Model contents","Test vacancy creation on newly provisioned workspaces"],"tags":["sequence-missing","migration","recruit"],"backgroundTag":"sequence-object-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}