{"record":{"id":"7f3656febbcebdfb","repo":"hcengineering/platform","slug":"author-or-owner-not-found-header-author-or-h","errorCode":null,"errorMessage":"Author or owner not found: ${header.author} or ${header.owner}","messagePattern":"Author or owner not found: (.+?) or (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/importer/src/huly/huly.ts","lineNumber":788,"sourceCode":"      qualified: data.qualified !== undefined ? this.findAccountByName(data.qualified) : undefined,\n      manager: data.manager !== undefined ? this.findAccountByName(data.manager) : undefined,\n      qara: data.qara !== undefined ? this.findAccountByName(data.qara) : undefined,\n      docs: []\n    }\n  }\n\n  private async processControlledDocument (\n    header: HulyControlledDocumentHeader,\n    docPath: string,\n    id: Ref<ControlledDocument>,\n    metaId: Ref<DocumentMeta>\n  ): Promise<ImportControlledDocument> {\n    const codeMatch = path.basename(docPath).match(/^\\[([^\\]]+)\\]/)\n\n    const author = this.findEmployeeByName(header.author)\n    const owner = this.findEmployeeByName(header.owner)\n    if (author === undefined || owner === undefined) {\n      throw new Error(`Author or owner not found: ${header.author} or ${header.owner}`)\n    }\n\n    const templatePath = path.resolve(path.dirname(docPath), header.template)\n    if (!fs.existsSync(templatePath)) {\n      throw new Error(`Template file not found: ${templatePath}`)\n    }\n\n    const templateId = this.metadataRegistry.getRef(templatePath) as Ref<ControlledDocument>\n    const category = header.category !== undefined ? this.controlledDocumentCategories.get(header.category) : undefined\n    return {\n      id,\n      metaId,\n      class: documents.class.ControlledDocument,\n      title: header.title,\n      template: templateId,\n      code: codeMatch?.[1],\n      major: 0,\n      minor: 1,","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/huly/huly.ts#L770-L806","documentation":"When constructing a controlled document, the importer resolves both `header.author` and `header.owner` to Employee references via findEmployeeByName, which throws on unknown names. This guard compares against undefined to produce a clearer combined message, but since findEmployeeByName never returns undefined for unknown names, the resolution error surfaces before this check in practice — meaning the underlying cause is always an unresolvable author or owner name.","triggerScenarios":"Importing a controlled document whose front-matter `author:` or `owner:` names are not present in employeesByName (HulyFormatImporter → processControlledDocument path); typical when the named employees do not exist in the target workspace or their names differ.","commonSituations":"Authors who left the organization; documents authored by contractors never onboarded to the target workspace; name casing/spelling differences between the export and the target workspace's employee records.","solutions":["Ensure both author and owner exist as Employees in the target workspace with exactly matching names","Correct the author/owner front-matter fields in the document markdown to existing employee names","Reassign to a valid employee (e.g. the document maintainer) and re-run the import","Re-export after the target workspace employee records are aligned"],"exampleFix":"// before (doc front-matter)\nauthor: J. Doe\nowner: ghost-user\n// after\nauthor: Jane Doe\nowner: Jane Doe","handlingStrategy":"validation","validationCode":"for (const doc of controlledDocs) {\n  for (const field of ['author', 'owner'] as const) {\n    const name = doc.frontMatter[field]\n    if (typeof name === 'string' && !employeeNames.has(name)) {\n      throw new Error(`${doc.path}: ${field} \"${name}\" is not an employee in the target workspace`)\n    }\n  }\n}","typeGuard":"function hasResolvableAuthorOwner(h: { author: string; owner: string }, employees: Set<string>): boolean {\n  return employees.has(h.author) && employees.has(h.owner)\n}","tryCatchPattern":"try {\n  await importer.workspaceData(folder)\n} catch (e) {\n  if (e instanceof Error && (e.message.startsWith('Author or owner not found') || e.message.startsWith('Employee not found'))) {\n    console.error('Set author/owner to existing employees in the document front-matter:', e.message)\n  } else throw e\n}","preventionTips":["Always set author and owner to current employees of the target workspace","Use exact display names, free of abbreviations or nicknames","Reassign documents owned by departed employees before export/import","Pre-validate all front-matter author/owner fields against the employee directory"],"tags":["importer","employee-lookup","controlled-documents"],"backgroundTag":"referenced-entity-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}