hcengineering/platform · error · Error

kind is not specified

Error message

kind is not specified

What it means

Thrown in CreateApplication.svelte when the `kind` variable (Ref<TaskType>) is undefined at creation time. Applications require a kind reference, and the code blocks creation until one is provided.

Source

Thrown at plugins/recruit-resources/src/components/CreateApplication.svelte:126

  const dispatch = createEventDispatcher()
  const client = getClient()
  const hierarchy = client.getHierarchy()
  fillDefaults(hierarchy, doc, recruit.class.Applicant)

  export function canClose (): boolean {
    return (preserveCandidate || _candidate === undefined) && assignee === undefined
  }

  async function createApplication (): Promise<void> {
    if (selectedState === undefined) {
      throw new Error(`Please select initial state:${_space}`)
    }
    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant })
    if (sequence === undefined) {
      throw new Error('sequence object not found')
    }
    if (kind === undefined) {
      throw new Error('kind is not specified')
    }

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

    const candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })
    if (candidateInstance === undefined) {
      throw new Error('contact not found')
    }

    const ops = client.apply(undefined, recruitId + '.Create.CreateApplication')

    if (!client.getHierarchy().hasMixin(candidateInstance, recruit.mixin.Candidate)) {
      await ops.createMixin<Contact, Candidate>(
        candidateInstance._id,
        candidateInstance._class,
        candidateInstance.space,
        recruit.mixin.Candidate,
        {}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Pick a kind in the dialog before submitting
  2. Seed/load recruit TaskType documents so the selector has options
  3. Guard the submit action (canClose / button disabled) until kind is set
  4. Catch the error and prompt for kind selection

Example fix

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

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try {
  await createApplication()
} catch (err) {
  if (err instanceof Error && err.message === 'kind is not specified') {
    ui.notify('Select an application kind first.')
  } else throw err
}

Prevention

When it happens

Trigger: User submits CreateApplication without selecting a kind; the TaskType list for the recruit plugin failed to load so no kind could be chosen; component state lost the selection on navigation.

Common situations: Recruit task types not seeded in the workspace; form allows submit with default-empty selector; conditional rendering skipping the kind input while create still runs.

Related errors


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