{"record":{"id":"1f703af350ff5b48","repo":"hcengineering/platform","slug":"attribute-not-found-name","errorCode":null,"errorMessage":"attribute not found: ${name}","messagePattern":"attribute not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/core/src/hierarchy.ts","lineNumber":553,"sourceCode":"  getParentClass (_class: Ref<Class<Obj>>): Ref<Class<Obj>> {\n    const baseDomain = this.getDomain(_class)\n    const ancestors = this.getAncestors(_class)\n    let result: Ref<Class<Obj>> = _class\n    for (const ancestor of ancestors) {\n      try {\n        const domain = this.getClass(ancestor).domain\n        if (domain === baseDomain) {\n          result = ancestor\n        }\n      } catch {}\n    }\n    return result\n  }\n\n  getAttribute (classifier: Ref<Classifier>, name: string): AnyAttribute {\n    const attr = this.findAttribute(classifier, name)\n    if (attr === undefined) {\n      throw new Error('attribute not found: ' + name)\n    }\n    return attr\n  }\n\n  public findAttribute (classifier: Ref<Classifier>, name: string): AnyAttribute | undefined {\n    const list = [classifier]\n    const visited = new Set<Ref<Classifier>>()\n    while (list.length > 0) {\n      const cl = list.shift() as Ref<Classifier>\n      if (addNew(visited, cl)) {\n        const attribute = this.attributes.get(cl)?.get(name)\n        if (attribute !== undefined) {\n          return attribute\n        }\n        // Check ancestorsOf\n        list.push(...this.ancestorsOf(cl))\n      }\n    }","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/core/src/hierarchy.ts#L535-L571","documentation":"Hierarchy.getAttribute returns a required attribute of a classifier. It delegates to findAttribute, which walks the class and its ancestors looking for the attribute; if no ancestor defines it, this Error is thrown. It signals the requested attribute simply does not exist on the class hierarchy.","triggerScenarios":"Calling getAttribute with an attribute name that was never defined (missing ClassType attribute tx), a misspelled attribute key, or querying an attribute that only exists on a mixin not attached to the object/class.","commonSituations":"Model rename where old attribute keys remain in code or persisted data; expecting inherited attributes that were moved to a mixin; version mismatch between client code and loaded model definitions.","solutions":["Verify the attribute name against the class definition (and any mixins) in the model source","Use hierarchy.findAttribute(...) and handle undefined when the attribute is optional","Ensure the attribute-defining model tx has been applied to the hierarchy","Check whether the attribute lives on a mixin and use getMixin-based attribute lookup instead"],"exampleFix":"// before\nconst attr = hierarchy.getAttribute(obj._class, 'dueDate')\n// after\nconst attr = hierarchy.findAttribute(obj._class, 'dueDate')\nif (attr === undefined) {\n  console.warn(`Attribute dueDate missing on ${obj._class}; skipping`)\n  return\n}\n// use attr","handlingStrategy":"validation","validationCode":"const attr = hierarchy.findAttribute(classifier, name)\nif (attr === undefined) {\n  throw new Error(`Attribute '${name}' does not exist on ${String(classifier)} or its ancestors`)\n}\n// safe to use attr","typeGuard":"function hasAttribute(h: Hierarchy, c: Ref<Classifier>, name: string): boolean {\n  return h.findAttribute(c, name) !== undefined\n}","tryCatchPattern":"let attr: AnyAttribute\ntry {\n  attr = hierarchy.getAttribute(classifier, name)\n} catch (err) {\n  console.warn(`Skipping missing attribute ${name} on ${String(classifier)}`)\n  return undefined\n}","preventionTips":["Derive attribute names from model constants instead of string literals","Remember attributes may live on mixins - check getMixin-based lookups","After model renames, grep code and data for stale attribute keys","Keep client and server model versions in sync"],"tags":["hierarchy","attribute","schema-mismatch"],"backgroundTag":"attribute-not-defined","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}