hcengineering/platform · error

Invalid import schema in ${filePath}: ${errors.map((e) => `

Error message

Invalid import schema in ${filePath}: 
${errors.map((e) => `    * ${e}`).join(';\n')}

What it means

validateFormat runs each parsed document through validateSchema against its FormatSchema; any accumulated validation errors are aggregated into this single message listing each failing check with the source file path. It means the document's YAML/structure does not conform to the expected format schema (missing required fields, wrong types, bad paths).

Source

Thrown at packages/importer/src/huly/cards.ts:884

      isArray: true
    })

    optionalFields.set('attachments', {
      type: PathFieldType,
      isArray: true
    })

    return {
      requiredFields,
      optionalFields
    }
  }

  private validateFormat (data: Record<string, any>, schema: FormatSchema, filePath: string): void {
    const currentPath = path.dirname(filePath)
    const errors = validateSchema(data, schema, currentPath)
    if (errors.length > 0) {
      throw new Error(
        'Invalid import schema in ' +
          filePath +
          ': \n' +
          Array.from(errors)
            .map((e) => `    * ${e}`)
            .join(';\n') +
          '\n'
      )
    }
  }

  private validateFileExists (fileAbsPath: string): void {
    if (!fs.existsSync(fileAbsPath)) {
      throw new Error('File not found: ' + fileAbsPath)
    }
  }
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Read the `* item` lines in the message — each names a specific schema violation and field; fix them in the file at <filePath>.
  2. Compare the document's header against the corresponding FormatSchema definition (MasterTagSchema, TagSchema, etc.) for required fields and types.
  3. Validate YAML structure/indentation — a misindented key can silently become a wrong-typed or missing field.
  4. If schemas changed after an upgrade, migrate old files to the new schema version.

Example fix

# before — missing required title
class: card:class:Tag
# after
class: card:class:Tag
title: My Tag
Defensive patterns

Strategy: validation

Validate before calling

import { validateSchema } from '<importer>/schema'
function prevalidate(file: string, data: Record<string, any>, schema: FormatSchema): string[] {
  return validateSchema(data, schema, path.dirname(file))
}

Try / catch

try {
  await processor.masterTag(file)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Invalid import schema in')) {
    const items = e.message.split('\n').filter(l => l.trim().startsWith('*'))
    console.error(`Schema issues in file:\n${items.join('\n')}`)
  } else throw e
}

Prevention

When it happens

Trigger: Any import flow (masterTag, tag, cards) calling validateFormat with a file whose parsed data violates FormatSchema — missing required keys like `title`, wrong field types, or referenced paths failing schema-level checks.

Common situations: Hand-authored cards missing required header fields; renamed schema fields after an importer upgrade; YAML indentation mistakes producing wrong types (string vs number).

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/abb2b4f0b64ac2c4. Report an issue: GitHub.