hcengineering/platform · error

Status id is required when creating in static model. Missing

Error message

Status id is required when creating in static model. Missing for: ${name}

What it means

Identical validation to the lead model but for recruit: defineSpaceType iterates defaultApplicantStatuses and requires each static status to have a defined id so a Status doc can be created with builder.createDoc(core.class.Status, ...). Missing ids break the recruit model build deterministically.

Source

Thrown at models/recruit/src/spaceType.ts:111

    core.space.Model,
    {
      baseClass: plugin.class.Applicant,
      allowCreate: true,
      description: plugin.string.Application,
      icon: plugin.icon.Application,
      name: plugin.string.Application
    },
    plugin.descriptors.Application
  )

  const defaultStatuses: Ref<Status>[] = []

  // Create statuses for the default task type
  for (const status of defaultApplicantStatuses) {
    const { name, color, ofAttribute, id, category } = status

    if (id === undefined) {
      throw new Error('Status id is required when creating in static model. Missing for: ' + name)
    }

    defaultStatuses.push(id)

    builder.createDoc(
      core.class.Status,
      core.space.Model,
      {
        ofAttribute,
        name,
        color,
        category
      },
      id
    )
  }

  // Create default task type

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Assign a literal unique id to every entry in defaultApplicantStatuses in models/recruit/src/spaceType.ts.
  2. Audit the statuses list for undefined ids (console.log or a unit test asserting ids exist).
  3. Create genuinely dynamic statuses at runtime rather than in the static defaults array.

Example fix

// before
{ name: 'No Show', color: '#888', category: ApplicantStatusCategory.Lost }
// after
{ name: 'No Show', color: '#888', id: 'no-show', category: ApplicantStatusCategory.Lost }
Defensive patterns

Strategy: validation

Validate before calling

defaultApplicantStatuses.forEach(s => {
  if (s.id === undefined) throw new Error(`status '${s.name}' missing id`)
})

Type guard

function hasStaticId(s: { id?: string }): s is { id: string } & typeof s {
  return typeof s.id === 'string' && s.id.length > 0
}

Prevention

When it happens

Trigger: An entry in defaultApplicantStatuses lacks a literal id when the recruit model is created; occurs at model build/upgrade time via createModel -> defineSpaceType.

Common situations: Adding a new applicant hiring status without an id; copy-pasting a status entry and deleting the id line; data-driven statuses accidentally placed in the static defaults list.

Related errors


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