hcengineering/platform · error · Error

kind is not specified

Error message

kind is not specified

What it means

Thrown in CreateLead.svelte when the `kind` variable (Ref<TaskType>) is still undefined at creation time. The Lead requires a kind/task-type reference to be assigned, and the code refuses to create the lead without one.

Source

Thrown at plugins/lead-resources/src/components/CreateLead.svelte:92

  }

  $: if (_space === undefined) {
    if (funnels.find((it) => it._id === _space) === undefined) {
      _space = funnels[0]?._id
    }
  }

  $: funnel = funnels.find((it) => it._id === _space)

  let kind: Ref<TaskType> | undefined = undefined

  async function createLead () {
    const sequence = await client.findOne(core.class.Sequence, { attachedTo: lead.class.Lead })
    if (sequence === undefined || customer == null) {
      throw new Error('Lead  creation failed')
    }
    if (kind === undefined) {
      throw new Error('kind is not specified')
    }

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

    const value: AttachedData<Lead> = {
      status: state,
      number,
      identifier: `LEAD-${number}`,
      title,
      kind,
      rank: '',
      assignee: null,
      startDate: null,
      dueDate: null,
      ...object
    }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Choose a kind in the dialog before clicking create
  2. Disable the submit button until `kind` is set (validate in canClose or form logic)
  3. Ensure lead TaskType objects exist and are loaded (run plugin seed/migration)
  4. Catch the error and prompt the user to select a kind

Example fix

// before
if (kind === undefined) {
  throw new Error('kind is not specified')
}
// after
if (kind === undefined) {
  ui.notify('Please select a lead kind before creating')
  return
}
Defensive patterns

Strategy: validation

Validate before calling

if (kind === undefined) {
  ui.notify('Kind is required')
  return
}
await createLead()

Type guard

function hasKind (kind: Ref<TaskType> | undefined): kind is Ref<TaskType> {
  return kind !== undefined
}

Try / catch

try {
  await createLead()
} catch (err) {
  if (err instanceof Error && err.message === 'kind is not specified') {
    ui.notify('Please pick a lead kind and try again.')
  } else throw err
}

Prevention

When it happens

Trigger: User submits the CreateLead form without picking a kind from the selector, or the kinds list failed to load leaving `kind` undefined even after an attempted selection.

Common situations: TaskType documents not seeded in the workspace so the dropdown is empty; UI allows submit while kind selector is untouched; event binding failure leaving the variable unset.

Related errors


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