hcengineering/platform · error

Board not found

Error message

Board not found

What it means

createCard in CreateCard.svelte looks up the Board document by _space id; if client.findOne(board.class.Board, { _id: _space }) returns undefined it throws 'Board not found'. The card creation UI was opened with a space reference that no longer resolves to an actual Board.

Source

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

  let _space = space
  const status: Status = OK

  let title: string = ''

  const dispatch = createEventDispatcher()
  const client = getClient()
  const cardId = generateId<BoardCard>()

  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)

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Re-fetch the list of boards and have the user reopen the dialog with a valid board selected.
  2. Check that the user has permission to read the board — a restricted board also returns undefined.
  3. Close the dialog automatically when the underlying board is deleted (subscribe to object removal).
  4. Log the _space value and compare it against existing board ids to identify the stale reference.

Example fix

// before
const sp = await client.findOne(board.class.Board, { _id: _space as Ref<Board> })
if (sp === undefined) {
  throw new Error('Board not found')
}
// after
const sp = await client.findOne(board.class.Board, { _id: _space as Ref<Board> })
if (sp === undefined) {
  ui.notify('This board no longer exists or is unavailable. Please select another board.')
  closeDialog()
  return
}
Defensive patterns

Strategy: type-guard

Validate before calling

const sp = await client.findOne(board.class.Board, { _id: _space as Ref<Board> })
if (sp === undefined) {
  // board deleted, restricted, or _space unset — abort before creating
  return
}

Type guard

function isBoard(doc: Board | undefined): doc is Board {
  return doc !== undefined && typeof doc._id === 'string' && doc._class === board.class.Board
}

Try / catch

try {
  await createCard()
} catch (err) {
  if (err instanceof Error && err.message === 'Board not found') {
    ui.notify('This board is no longer available. Please reopen the dialog and select a board.')
    closeDialog()
  } else throw err
}

Prevention

When it happens

Trigger: The _space variable holds a stale/invalid Ref<Board> — the board was deleted, the user lacks access so the object isn't loaded, or _space was never set before createCard ran.

Common situations: Another user deleted the board while the create-card dialog was open, navigating to the dialog via a stale link, or a permission/scope issue hiding the board from the current user's client.

Related errors


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