hcengineering/platform · error

Employee not found: ${name}

Error message

Employee not found: ${name}

What it means

findEmployeeByName maps a person name to an Employee reference using the employeesByName map built from the target workspace. Called from author, owner, and controlled-document processing; an unknown name throws because documents require a valid employee for author/owner attribution.

Source

Thrown at packages/importer/src/huly/huly.ts:559

    }

    this.personIdByEmail.set(email, socialId._id)

    return socialId._id
  }

  private findAccountByName (name: string): AccountUuid {
    const account = this.accountsByName.get(name)
    if (account === undefined) {
      throw new Error(`Account not found: ${name}`)
    }
    return account
  }

  private findEmployeeByName (name: string): Ref<Employee> {
    const employee = this.employeesByName.get(name)
    if (employee === undefined) {
      throw new Error(`Employee not found: ${name}`)
    }
    return employee
  }

  private async processDocumentsRecursively (
    builder: ImportWorkspaceBuilder,
    teamspacePath: string,
    currentPath: string,
    parentDocPath?: string
  ): Promise<void> {
    const docFiles = fs.readdirSync(currentPath).filter((f) => f.endsWith('.md'))

    for (const docFile of docFiles) {
      const docPath = path.join(currentPath, docFile)
      const docHeader = this.parser.readYamlHeader(docPath) as HulyDocumentHeader

      if (docHeader.class === undefined) {
        this.logger.error(`Skipping ${docFile}: not a document`)

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify each named author/owner exists as an Employee in the target workspace
  2. Fix the name in the document front-matter to exactly match an existing employee
  3. Reassign author/owner fields to a current employee in the exported markdown
  4. Re-export after employees are created in the target workspace

Example fix

// before (doc front-matter)
author: Bob
owner: Alice
// after
author: Robert Brown
owner: Alice Green
Defensive patterns

Strategy: validation

Validate before calling

const names = docs.flatMap(d => [d.frontMatter.author, d.frontMatter.owner]).filter(Boolean)
const missing = [...new Set(names)].filter(n => !employeeNames.has(n))
if (missing.length) throw new Error(`Missing employees: ${missing.join(', ')}`)

Try / catch

try {
  await importer.workspaceData(folder)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Employee not found:')) {
    const name = e.message.slice('Employee not found:'.length).trim()
    console.error(`Onboard or remap employee "${name}" before importing controlled documents`)
  } else throw e
}

Prevention

When it happens

Trigger: Processing a controlled document (or its template) whose front-matter `author`/`owner` names, or document author fields, do not match any employee in employeesByName — the person is not an employee of the target workspace or the name differs.

Common situations: Importing controlled documents into a workspace where the named authors were never onboarded; former employees no longer in the workspace; name spelling/casing/whitespace mismatches between export and target.

Related errors


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