{"record":{"id":"447b4bd83f54e75b","repo":"hcengineering/platform","slug":"sequence-object-not-found-447b4b","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/CreateOpinion.svelte","lineNumber":57,"sourceCode":"    _id: generateId(),\n    collection: 'reviews',\n    modifiedOn: Date.now(),\n    modifiedBy: '' as PersonId,\n    description: '',\n    value: ''\n  }\n\n  const dispatch = createEventDispatcher()\n  const client = getClient()\n\n  export function canClose (): boolean {\n    return review === undefined && assignee === undefined\n  }\n\n  async function createOpinion () {\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 reviewInstance = await client.findOne(recruit.class.Review, { _id: doc.attachedTo })\n    if (reviewInstance === undefined) {\n      throw new Error('contact not found')\n    }\n\n    await client.addCollection(\n      recruit.class.Opinion,\n      reviewInstance.space,\n      doc.attachedTo,\n      doc.attachedToClass,\n      'opinions',\n      {\n        number: (incResult as any).object.sequence,\n        description: doc.description,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/review/CreateOpinion.svelte#L39-L75","documentation":"CreateOpinion.svelte looks up the core Sequence object attached to `recruit.class.Review` to generate a sequential number (name) for the new opinion. If no Sequence document exists for Review, the numbering scheme cannot be incremented and the component throws. Sequence objects are normally seeded when the Review class is registered with a numbering pattern.","triggerScenarios":"Calling createOpinion when `client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })` returns undefined — i.e. the Sequence document for Review was never created in the current workspace or was deleted.","commonSituations":"Fresh workspaces created before the sequence-seeding migration ran, a backup restore missing sequence documents, deleted Sequence docs from a data cleanup, or a plugin upgrade that renamed the class without migrating sequences.","solutions":["Create the missing Sequence object for recruit.class.Review (e.g. via the generateSequence helper / plugin setup) in the workspace.","Re-run the sequence generation/upgrade routine so sequences are seeded for all numbered classes.","Instead of throwing, create the sequence lazily: if findOne returns undefined, call createDoc with an initial sequence value.","Verify with a query that a Sequence doc with attachedTo=recruit.class.Review exists in the affected workspace."],"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  // seed it before proceeding\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 createOpinion()\n} catch (e) {\n  if (e.message === 'sequence object not found') {\n    await seedSequence(recruit.class.Review)\n    await createOpinion()\n  } else throw e\n}","preventionTips":["Run sequence-seeding migrations on every workspace create/upgrade","Never delete core.space.Model documents manually","Verify Sequence docs after backup restores"],"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"}