{"record":{"id":"d473dd94e8d0099d","repo":"hcengineering/platform","slug":"invalid-master-tag-data","errorCode":null,"errorMessage":"Invalid master tag data","messagePattern":"Invalid master tag data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/importer/src/huly/cards.ts","lineNumber":335,"sourceCode":"        childCardPath,\n        cardProps,\n        masterTagId,\n        masterTagAssociaions,\n        masterTagAttributes,\n        parentCardId\n      )\n    }\n  }\n\n  private async createMasterTag (\n    data: Record<string, any>,\n    filePath: string,\n    parentMasterTagId?: Ref<MasterTag>\n  ): Promise<UnifiedDoc<MasterTag>> {\n    this.validateFormat(data, MasterTagSchema, filePath)\n    const { class: _class, title } = data\n    if (_class !== card.class.MasterTag) {\n      throw new Error('Invalid master tag data')\n    }\n\n    return {\n      _class: card.class.MasterTag,\n      props: {\n        _id: this.metadataRegistry.getRef(filePath) as Ref<MasterTag>,\n        space: core.space.Model,\n        extends: parentMasterTagId ?? card.class.Card,\n        label: ('embedded:embedded:' + title) as IntlString,\n        kind: 0,\n        icon: card.icon.MasterTag\n      }\n    }\n  }\n\n  private async processTag (\n    tagPath: string,\n    tagConfig: Record<string, any>,","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/huly/cards.ts#L317-L353","documentation":"Thrown by CardsProcessor.createMasterTag after schema validation passes but the parsed document's `class` field does not equal card.class.MasterTag. It is an internal consistency check ensuring only master-tag documents reach master tag creation; a mismatch means the file declared a different class in its YAML header.","triggerScenarios":"Calling masterTag (or a flow that routes to createMasterTag) with data parsed from a file whose YAML header `class:` is not card.class.MasterTag — e.g. a Tag or plain Card document passed to the wrong factory.","commonSituations":"Routing a mixed directory of tags and master tags through the masterTag entry point; copy-pasted headers where `class:` was left as `card:class:Tag`; dispatch code that maps files to creators by extension rather than class.","solutions":["Set the file's YAML `class:` header to exactly the card.class.MasterTag value expected by the importer version.","Route the document to the correct factory (createTag/createCard) based on its `class` instead of calling createMasterTag.","Verify no typo/case mismatch in the class string (e.g. `card:class:mastertag` vs `card:class:MasterTag`)."],"exampleFix":"// before (YAML header)\nclass: card:class:Tag\ntitle: Priority\n// after\nclass: card:class:MasterTag\ntitle: Priority","handlingStrategy":"type-guard","validationCode":"function assertMasterTagFile(header: { class?: string }): boolean {\n  return header.class === 'card:class:MasterTag' // match card.class.MasterTag for your version\n}","typeGuard":"function isMasterTagData(d: { class?: string; title?: string }): d is { class: typeof card.class.MasterTag; title: string } {\n  return d.class === card.class.MasterTag && typeof d.title === 'string'\n}","tryCatchPattern":"try {\n  await processor.masterTag(file)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Invalid master tag data') {\n    console.error(`${file}: class header is not card.class.MasterTag — route to the correct factory or fix the header`)\n  } else throw e\n}","preventionTips":["Dispatch documents to factories by their parsed `class` value, not by filename or directory.","Reference card.class.MasterTag constant instead of hardcoding the string.","Keep one canonical master-tag template in the repo."],"tags":["importer","validation","master-tag"],"backgroundTag":"mismatched-document-class","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}