hcengineering/platform · error · Error

Invalid ${type} at ${path}: \n${errors.map((e) => ` * ${e

Error message

Invalid ${type} at ${path}: \n${errors.map((e) => `    * ${e}`).join('\n')}

What it means

WorkspaceBuilder.validateAndAdd runs the per-type validator on an item before storing it. If validation returns errors, it records them via addError and — only in strictMode — throws 'Invalid <type> at <path>' with the bulleted list of validation messages. In non-strict mode the item is not added but importing continues.

Source

Thrown at packages/importer/src/importer/builder.ts:328

      if (template.docPrefix !== undefined) {
        this.qmsTemplatePrefixCache.add(template.docPrefix)
      }
    }
  }

  private validateAndAdd<T, K>(
    type: string,
    path: string,
    item: T,
    validator: (item: T) => string[],
    collection: Map<K, T>,
    key?: K
  ): void {
    const errors = validator(item)
    if (errors.length > 0) {
      this.addError(path, `Invalid ${type} at ${path}: \n${errors.map((e) => `    * ${e}`).join('\n')}`)
      if (this.strictMode) {
        throw new Error(`Invalid ${type} at ${path}: \n${errors.map((e) => `    * ${e}`).join('\n')}`)
      }
    } else {
      collection.set((key ?? path) as K, item)
    }
  }

  private validateProjectType (projectType: ImportProjectType): string[] {
    const errors: string[] = []
    if (!this.validateStringDefined(projectType.name)) {
      errors.push('name is required')
    }
    return errors
  }

  private validateProject (project: ImportProject): string[] {
    const errors: string[] = []

    errors.push(...this.validateType(project.title, 'string', 'title'))

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Fix the data at <path> per the bulleted validation messages in the error and re-add the item.
  2. Validate your source records before passing them to the builder's add* methods (check required fields and reference targets).
  3. Run the import with strictMode=false to collect all validation errors instead of failing on the first one, then fix them in batch.
  4. Check ordering: register referenced entities (projects, teamspaces, spaces) before items that depend on them.

Example fix

// before
builder.addIssue(projectPath, issuePath, { number: 42 } as ImportIssue)
// after — include required fields
builder.addIssue(projectPath, issuePath, {
  number: 42,
  title: 'Fix login',
  description: 'Login fails on SSO',
  state: 'todo'
})
Defensive patterns

Strategy: validation

Validate before calling

// validate items before add*
const errors = validateProject(project) // same rules as builder's validator
if (errors.length > 0) {
  throw new Error(`Refusing to add invalid project at ${path}: ${errors.join('; ')}`)
}
builder.addProject(path, project)

Try / catch

try {
  builder.addIssue(projectPath, issuePath, issue)
} catch (e) {
  if ((e as Error).message.startsWith('Invalid issue at')) {
    console.error(`Fix data at ${issuePath}: ${e.message}`)
  } else throw e
}

Prevention

When it happens

Trigger: Calling addProjectType/addProject/addTeamspace/addIssue/addDocument/addOrgSpace with an item whose validator returns a non-empty error array while strictMode is on (the throw path at builder.ts:329).

Common situations: Missing required fields (e.g. issue without number, project without name/type); values of wrong type from hand-built import data; items referencing undefined projects/spaces; programmatic generation of import data with gaps.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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