hcengineering/platform · critical

sequence object not found

Error message

sequence object not found

What it means

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.

Source

Thrown at plugins/board-resources/src/components/add-card/AddCard.svelte:35

  import board from '../../plugin'
  import core, { AttachedData, generateId, Ref, Space } from '@hcengineering/core'
  import { IconAdd, Button, showPopup } from '@hcengineering/ui'
  import { getClient } from '@hcengineering/presentation'
  import AddCardEditor from './AddCardEditor.svelte'
  import AddMultipleCardsPopup from './AddMultipleCardsPopup.svelte'

  export let space: Ref<Space>
  export let state: any

  let anchorRef: HTMLDivElement
  const client = getClient()

  async function addCard (title: string) {
    const newCardId = generateId()

    const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })
    if (sequence === undefined) {
      throw new Error('sequence object not found')
    }

    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)

    const value: AttachedData<BoardCard> = {
      status: state._id,
      number: (incResult as any).object.sequence,
      title,
      rank: '',
      assignee: null,
      description: '',
      members: [],
      location: '',
      startDate: null,
      dueDate: null
    }

    return await client.addCollection(board.class.Card, space, space, board.class.Board, 'cards', value, newCardId)

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Run workspace upgrade/initialization so sequences for board.class.Card are generated.
  2. Create the missing Sequence document via a migration or admin tool.
  3. Check that the query's attachedTo class matches the class the sequence was seeded with.

Example fix

// before
const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })
if (sequence === undefined) throw new Error('sequence object not found')
// after
const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })
if (sequence === undefined) {
  await showError(plugin.string.SequenceMissing)
  return
}
Defensive patterns

Strategy: try-catch

Validate before calling

const sequence = await client.findOne(core.class.Sequence, { attachedTo: board.class.Card })
if (sequence === undefined) return // or create the sequence lazily before proceeding

Type guard

function isSequence(s: Sequence | undefined): s is Sequence { return s != null }

Try / catch

try {
  await addCard(title)
} catch (e) {
  if (e instanceof Error && e.message === 'sequence object not found') {
    ui.notify('Cannot add card: numbering sequence missing')
  } else throw e
}

Prevention

When it happens

Trigger: `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.

Common situations: 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).

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/ea5c6b89657aadf3. Report an issue: GitHub.