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

When the lead model's defineSpaceType creates its default task type, it registers each defaultLeadStatuses entry as a static Status doc. Static statuses must have a predefined id so they are stable across deployments; if id is undefined the model builder cannot create the status and throws, naming the offending status.

Source

Thrown at models/lead/src/spaceType.ts:120

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

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

  // Create statuses for the default task type
  for (const status of defaultLeadStatuses) {
    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. Add a unique literal id to the offending status entry in defaultLeadStatuses (models/lead/src/spaceType.ts / plugin config).
  2. Check all entries of defaultLeadStatuses for undefined ids before createModel runs.
  3. If a status is dynamic, move it out of the default (static) status list into runtime status creation instead.

Example fix

// before
{ name: 'Blocked', color: '#f00', category: LeadStatusCategory.New } // id missing
// after
{ name: 'Blocked', color: '#f00', id: 'blocked', category: LeadStatusCategory.New }
Defensive patterns

Strategy: validation

Validate before calling

defaultLeadStatuses.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: Adding or editing an entry in defaultLeadStatuses in the lead model without assigning a literal id; a typo like 'ide' or a conditionally undefined id expression.

Common situations: Contributing a new lead status (e.g. a new pipeline stage) and forgetting the id; merging model changes where someone removed the id; TypeScript not catching it because the status objects are loosely typed at the call site.

Related errors


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