hcengineering/platform · error · Error

create application: state not found space:${_space}

Error message

create application: state not found space:${_space}

What it means

In MoveApplication.svelte, updateApplication throws this when `selectedState` is still undefined after the state-selection step. The developer intended to move selected applications into space `_space` with a chosen initial state; without a selected state the application cannot be created in the target space. Note the guard is a copy-paste bug: it re-checks `selectedState === undefined` (the first check should test something else, e.g. selected application), so this error fires whenever no initial state was picked.

Source

Thrown at plugins/recruit-resources/src/components/MoveApplication.svelte:65

  export let selected: Applicant[]

  const status: Status = OK

  let _space = selected[0]?.space

  const dispatch = createEventDispatcher()
  const client = getClient()

  export function canClose (): boolean {
    return true
  }

  async function updateApplication () {
    if (selectedState === undefined) {
      throw new Error(`Please select initial state:${_space}`)
    }
    if (selectedState === undefined) {
      throw new Error(`create application: state not found space:${_space}`)
    }

    const op = client.apply(undefined, 'application.states')

    for (const a of selected) {
      await moveToSpace(op, a, _space, { status: selectedState._id })
    }
    await op.commit()
    dispatch('close')
  }

  let states: Array<{ id: number | string, color: number, label: string }> = []
  let selectedState: TaskStatus | undefined
  let rawStates: TaskStatus[] = []
  const spaceQuery = createQuery()

  let vacancy: Vacancy | undefined

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Select an initial state in the MoveApplication dialog before confirming.
  2. Fix the duplicated guard: the second check should validate a different precondition (e.g. `selected.length === 0`) so the message matches the actual failure.
  3. Ensure the target space has state objects defined for `application.states` so the selector can be populated.
  4. Disable the submit button until a state is selected to prevent reaching the throw.

Example fix

// before
if (selectedState === undefined) {
  throw new Error(`create application: state not found space:${_space}`)
}
// after
if (selectedState === undefined) {
  notification(zot) // or otherwise surface a UI validation message
  return
}
if (selected.length === 0) {
  throw new Error(`no applications selected space:${_space}`)
}
Defensive patterns

Strategy: validation

Validate before calling

if (selectedState === undefined) {
  alert('Please select an initial state before moving applications.')
  return
}

Try / catch

try {
  await updateApplication()
} catch (e) {
  if (e.message.startsWith('create application: state not found')) {
    showNotification('Select an initial state first')
  } else throw e
}

Prevention

When it happens

Trigger: User clicks the move/apply action in the MoveApplication dialog without choosing an initial state from the state selector, so `selectedState` remains undefined when updateApplication runs.

Common situations: The state list for the target space failed to load or is empty (no states defined for the space's class), the user skipped the dropdown, or the selected state was reset when the target space changed.

Related errors


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