{"record":{"id":"243f5313852e5c82","repo":"hcengineering/platform","slug":"sequence-object-not-found-243f53","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/CreateApplication.svelte","lineNumber":123,"sourceCode":"    isDone: false\n  }\n\n  const dispatch = createEventDispatcher()\n  const client = getClient()\n  const hierarchy = client.getHierarchy()\n  fillDefaults(hierarchy, doc, recruit.class.Applicant)\n\n  export function canClose (): boolean {\n    return (preserveCandidate || _candidate === undefined) && assignee === undefined\n  }\n\n  async function createApplication (): Promise<void> {\n    if (selectedState === undefined) {\n      throw new Error(`Please select initial state:${_space}`)\n    }\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant })\n    if (sequence === undefined) {\n      throw new Error('sequence object not found')\n    }\n    if (kind === undefined) {\n      throw new Error('kind is not specified')\n    }\n\n    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)\n\n    const candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })\n    if (candidateInstance === undefined) {\n      throw new Error('contact not found')\n    }\n\n    const ops = client.apply(undefined, recruitId + '.Create.CreateApplication')\n\n    if (!client.getHierarchy().hasMixin(candidateInstance, recruit.mixin.Candidate)) {\n      await ops.createMixin<Contact, Candidate>(\n        candidateInstance._id,\n        candidateInstance._class,","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/CreateApplication.svelte#L105-L141","documentation":"Thrown in CreateApplication.svelte when the Sequence object for recruit.class.Applicant is missing. Sequences supply incrementing application numbers; without the sequence document the code cannot allocate a number and aborts creation.","triggerScenarios":"client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant }) returns undefined because the sequence was never seeded, was deleted, or migrations have not run for the workspace.","commonSituations":"Fresh or partially-migrated recruit plugin workspace; sequence object removed by cleanup tooling; data restore that skipped sequence documents.","solutions":["Run workspace migrations/seed so the Applicant sequence object is created","Re-create the sequence manually with attachedTo: recruit.class.Applicant","Verify with a query that core.class.Sequence attachedTo=Applicant exists before opening the dialog","Catch the error and trigger sequence seeding then retry"],"exampleFix":"// before\nconst sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant })\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.Applicant })\nif (sequence === undefined) {\n  sequence = await client.createDoc(core.class.Sequence, core.space.Model, {\n    attachedTo: recruit.class.Applicant, sequence: 0\n  })\n}","handlingStrategy":"validation","validationCode":"const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant })\nif (sequence === undefined) {\n  await ensureSequence(recruit.class.Applicant, 0)\n}","typeGuard":"function hasSequence (s: Sequence | undefined): s is Sequence {\n  return s !== undefined\n}","tryCatchPattern":"try {\n  await createApplication()\n} catch (err) {\n  if (err instanceof Error && err.message === 'sequence object not found') {\n    await seedSequences()\n    return createApplication()\n  }\n  throw err\n}","preventionTips":["Seed sequences for all numbered classes in migrations","Guard migrations to re-create missing sequences idempotently","Do not delete core.space.Model documents during cleanups","Smoke-test application creation on fresh 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"}