{"record":{"id":"0b8219549a34ee34","repo":"hcengineering/platform","slug":"create-application-state-not-found-space-space","errorCode":null,"errorMessage":"create application: state not found space:${_space}","messagePattern":"create application: state not found space:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/recruit-resources/src/components/MoveApplication.svelte","lineNumber":65,"sourceCode":"  export let selected: Applicant[]\n\n  const status: Status = OK\n\n  let _space = selected[0]?.space\n\n  const dispatch = createEventDispatcher()\n  const client = getClient()\n\n  export function canClose (): boolean {\n    return true\n  }\n\n  async function updateApplication () {\n    if (selectedState === undefined) {\n      throw new Error(`Please select initial state:${_space}`)\n    }\n    if (selectedState === undefined) {\n      throw new Error(`create application: state not found space:${_space}`)\n    }\n\n    const op = client.apply(undefined, 'application.states')\n\n    for (const a of selected) {\n      await moveToSpace(op, a, _space, { status: selectedState._id })\n    }\n    await op.commit()\n    dispatch('close')\n  }\n\n  let states: Array<{ id: number | string, color: number, label: string }> = []\n  let selectedState: TaskStatus | undefined\n  let rawStates: TaskStatus[] = []\n  const spaceQuery = createQuery()\n\n  let vacancy: Vacancy | undefined\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/MoveApplication.svelte#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Select an initial state in the MoveApplication dialog before confirming.","Fix the duplicated guard: the second check should validate a different precondition (e.g. `selected.length === 0`) so the message matches the actual failure.","Ensure the target space has state objects defined for `application.states` so the selector can be populated.","Disable the submit button until a state is selected to prevent reaching the throw."],"exampleFix":"// before\nif (selectedState === undefined) {\n  throw new Error(`create application: state not found space:${_space}`)\n}\n// after\nif (selectedState === undefined) {\n  notification(zot) // or otherwise surface a UI validation message\n  return\n}\nif (selected.length === 0) {\n  throw new Error(`no applications selected space:${_space}`)\n}","handlingStrategy":"validation","validationCode":"if (selectedState === undefined) {\n  alert('Please select an initial state before moving applications.')\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await updateApplication()\n} catch (e) {\n  if (e.message.startsWith('create application: state not found')) {\n    showNotification('Select an initial state first')\n  } else throw e\n}","preventionTips":["Disable the confirm button until selectedState is set","Fix the duplicated undefined guard so messages match conditions","Ensure target spaces always have states seeded"],"tags":["ui","validation","state-management","copy-paste-bug"],"backgroundTag":"required-state-not-selected","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}