hcengineering/platform · error · Error
Please select initial state:${_space}
Error message
Please select initial state:${_space} What it means
Thrown in CreateApplication.svelte when `selectedState` is undefined at application creation time. An application must be placed into an initial state of the target vacancy/space, so the code refuses to proceed without one. The message includes the space name to help identify which project lacks a state selection.
Source
Thrown at plugins/recruit-resources/src/components/CreateApplication.svelte:119
modifiedBy: '' as PersonId,
startDate: null,
dueDate: null,
kind: '' as Ref<TaskType>,
isDone: false
}
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')
View on GitHub (pinned to 63e28dc964)
Solutions
- Select an initial state in the dialog before creating the application
- Ensure the target space has default states configured (inherit states from project type)
- Disable the create button until selectedState is defined
- Catch the error and show a picker prompt instead of throwing
Example fix
// before
if (selectedState === undefined) {
throw new Error(`Please select initial state:${_space}`)
}
// after
if (selectedState === undefined) {
ui.notify(`Please select an initial state for ${_space}`)
return
} Defensive patterns
Strategy: validation
Validate before calling
if (selectedState === undefined) {
ui.notify(`Select an initial state for ${_space}`)
return
}
await createApplication() Type guard
function hasState (state: Ref<DomainState> | undefined): state is Ref<DomainState> {
return state !== undefined
} Try / catch
try {
await createApplication()
} catch (err) {
if (err instanceof Error && err.message.startsWith('Please select initial state')) {
ui.notify('Choose an initial state before creating the application.')
} else throw err
} Prevention
- Disable create until a state is selected
- Preselect the first/default state of the space
- Ensure target spaces inherit states from their project type
- Validate state availability when the space changes
When it happens
Trigger: User submits the CreateApplication dialog without choosing an initial state; the target space's states failed to load so the selector stays empty; state filter for the space returns no done-less states.
Common situations: New vacancy whose state machine was not set up; UI not blocking submit when state dropdown untouched; states not migrated for a copied/merged space.
Related errors
- Please select initial state:${_space}
- kind is not specified
- kind is not specified
- Failed to load server config
- getDisplayMedia not supported
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/340c1980ebb1d660.
Report an issue: GitHub.