hcengineering/platform · error

Status not found

Error message

Status not found

What it means

createCard in CreateCard.svelte throws 'Status not found' when no core.class.Status document exists for space: sp.type. Card creation needs at least one status (typically the first by rank) to assign to the new card; a board type without any defined statuses cannot accept cards.

Source

Thrown at plugins/board-resources/src/components/CreateCard.svelte:55

  export function canClose (): boolean {
    return title !== ''
  }

  let kind: Ref<TaskType> | undefined = undefined

  async function createCard () {
    const sp = await client.findOne(board.class.Board, { _id: _space as Ref<Board> })
    if (sp === undefined) {
      throw new Error('Board not found')
    }
    const status = await client.findOne(
      core.class.Status,
      { space: sp.type },
      { sort: { rank: SortingOrder.Ascending } }
    )
    if (status === undefined) {
      throw new Error('Status not found')
    }
    if (kind === undefined) {
      throw new Error('kind is not specified')
    }
    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 number = (incResult as any).object.sequence

    const value: AttachedData<BoardCard> = {
      status: status._id,
      number,
      title,
      kind,

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Initialize default statuses for the board's task type (run the plugin's seed/init routine that creates statuses for sp.type).
  2. Verify the board's type reference is correct — statuses may exist under a different space id.
  3. Check for deletions of Status documents and restore them.
  4. Guard the UI: disable card creation for types that have no statuses and prompt an admin to configure them.

Example fix

// before
const status = await client.findOne(core.class.Status, { space: sp.type }, { sort: { rank: SortingOrder.Ascending } })
if (status === undefined) {
  throw new Error('Status not found')
}
// after
const status = await client.findOne(core.class.Status, { space: sp.type }, { sort: { rank: SortingOrder.Ascending } })
if (status === undefined) {
  await ensureDefaultStatuses(client, sp.type) // seed defaults for this type
  status = await client.findOne(core.class.Status, { space: sp.type }, { sort: { rank: SortingOrder.Ascending } })
}
Defensive patterns

Strategy: validation

Validate before calling

const status = await client.findOne(core.class.Status, { space: sp.type }, { sort: { rank: SortingOrder.Ascending } })
if (status === undefined) {
  throw new Error(`Task type ${sp.type} has no statuses; seed defaults before allowing card creation`)
}

Type guard

function typeHasStatuses(statuses: Status[]): statuses is [Status, ...Status[]] {
  return statuses.length > 0
}

Try / catch

try {
  await createCard()
} catch (err) {
  if (err instanceof Error && err.message === 'Status not found') {
    ui.notify('This board type has no statuses configured. Ask an admin to set them up.')
  } else throw err
}

Prevention

When it happens

Trigger: Querying statuses with { space: sp.type } returns an empty result because the board's type (task type) was never initialized with default statuses, or its statuses were deleted.

Common situations: Custom/newly created task types missing the default status seed data, migrations that dropped statuses, or boards created against a type whose status initialization step failed.

Related errors


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