{"record":{"id":"ea5c6b89657aadf3","repo":"hcengineering/platform","slug":"sequence-object-not-found-ea5c6b","errorCode":null,"errorMessage":"sequence object not found","messagePattern":"sequence object not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"plugins/board-resources/src/components/add-card/AddCard.svelte","lineNumber":35,"sourceCode":"  import board from '../../plugin'\n  import core, { AttachedData, generateId, Ref, Space } from '@hcengineering/core'\n  import { IconAdd, Button, showPopup } from '@hcengineering/ui'\n  import { getClient } from '@hcengineering/presentation'\n  import AddCardEditor from './AddCardEditor.svelte'\n  import AddMultipleCardsPopup from './AddMultipleCardsPopup.svelte'\n\n  export let space: Ref<Space>\n  export let state: any\n\n  let anchorRef: HTMLDivElement\n  const client = getClient()\n\n  async function addCard (title: string) {\n    const newCardId = generateId()\n\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })\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 value: AttachedData<BoardCard> = {\n      status: state._id,\n      number: (incResult as any).object.sequence,\n      title,\n      rank: '',\n      assignee: null,\n      description: '',\n      members: [],\n      location: '',\n      startDate: null,\n      dueDate: null\n    }\n\n    return await client.addCollection(board.class.Card, space, space, board.class.Board, 'cards', value, newCardId)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/board-resources/src/components/add-card/AddCard.svelte#L17-L53","documentation":"AddCard.svelte fetches the Sequence attached to `board.class.Card` to allocate the next card number; if findOne returns undefined the add operation aborts with this error. The sequence is required before incrementing and creating the attached card document.","triggerScenarios":"`client.findOne(core.class.Sequence, { attachedTo: board.class.Card })` returns undefined when a user clicks add-card on a board whose sequence object is absent from the workspace.","commonSituations":"Workspaces created before sequence seeding was added, databases where the upgrade/migration did not run, or a board class mismatch (sequence attached to a different class).","solutions":["Run workspace upgrade/initialization so sequences for board.class.Card are generated.","Create the missing Sequence document via a migration or admin tool.","Check that the query's attachedTo class matches the class the sequence was seeded with."],"exampleFix":"// before\nconst sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })\nif (sequence === undefined) throw new Error('sequence object not found')\n// after\nconst sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })\nif (sequence === undefined) {\n  await showError(plugin.string.SequenceMissing)\n  return\n}","handlingStrategy":"try-catch","validationCode":"const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })\nif (sequence === undefined) return // or create the sequence lazily before proceeding","typeGuard":"function isSequence(s: Sequence | undefined): s is Sequence { return s != null }","tryCatchPattern":"try {\n  await addCard(title)\n} catch (e) {\n  if (e instanceof Error && e.message === 'sequence object not found') {\n    ui.notify('Cannot add card: numbering sequence missing')\n  } else throw e\n}","preventionTips":["Ensure migrations/seed scripts create Sequence objects for board.class.Card in every workspace.","Lazily create the sequence if missing instead of failing hard.","Verify database snapshots used for environments include sequence seed data."],"tags":["data-model","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"}