{"record":{"id":"b4b4a377456d4746","repo":"hcengineering/platform","slug":"sequence-object-not-found-b4b4a3","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/review/CreateReview.svelte","lineNumber":92,"sourceCode":"    title,\n    participants: [currentUser],\n    eventId: '',\n    dueDate: 0,\n    calendar: '' as Ref<Calendar>\n  }\n\n  const dispatch = createEventDispatcher()\n  const client = getClient()\n  const hierarchy = client.getHierarchy()\n\n  export function canClose (): boolean {\n    return (preserveCandidate || candidate === undefined) && title.length === 0\n  }\n\n  async function createReview () {\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })\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\n    const candidateInstance = await client.findOne(contact.class.Person, { _id: doc.attachedTo as Ref<Person> })\n    if (candidateInstance === undefined) {\n      throw new Error('contact not found')\n    }\n    if (!client.getHierarchy().hasMixin(candidateInstance, recruit.mixin.Candidate)) {\n      await client.createMixin<Person, Candidate>(\n        candidateInstance._id,\n        candidateInstance._class,\n        candidateInstance.space,\n        recruit.mixin.Candidate,\n        {}\n      )\n    }\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/review/CreateReview.svelte#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Seed the missing Sequence object for recruit.class.Review via the generateSequence/setup routine.","Run the platform upgrade/migration that generates sequences for all classes with numbering patterns.","Create the sequence lazily in code when findOne returns undefined instead of throwing.","Audit the model space for Sequence docs attachedTo Review and re-create missing ones."],"exampleFix":"// before\nconst sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })\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.Review })\nif (sequence === undefined) {\n  sequence = await client.createDoc(core.class.Sequence, core.space.Model, {\n    attachedTo: recruit.class.Review,\n    sequence: 0\n  })\n}","handlingStrategy":"try-catch","validationCode":"const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })\nif (sequence === undefined) {\n  await client.createDoc(core.class.Sequence, core.space.Model, { attachedTo: recruit.class.Review, sequence: 0 })\n}","typeGuard":"function hasSequence(s: Sequence | undefined): s is Sequence { return s !== undefined }","tryCatchPattern":"try {\n  await createReview()\n} catch (e) {\n  if (e.message === 'sequence object not found') {\n    await seedSequence(recruit.class.Review)\n    await createReview()\n  } else throw e\n}","preventionTips":["Ensure upgrade routines seed sequences for all numbered classes","Include Sequence docs in backup/restore verification","Do not clean up model-space Sequence objects"],"tags":["database","missing-data","sequence"],"backgroundTag":"missing-sequence-object","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}