hcengineering/platform · error · Error
attribute not found: ${name}
Error message
attribute not found: ${name} What it means
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.
Source
Thrown at foundations/core/packages/core/src/hierarchy.ts:553
getParentClass (_class: Ref<Class<Obj>>): Ref<Class<Obj>> {
const baseDomain = this.getDomain(_class)
const ancestors = this.getAncestors(_class)
let result: Ref<Class<Obj>> = _class
for (const ancestor of ancestors) {
try {
const domain = this.getClass(ancestor).domain
if (domain === baseDomain) {
result = ancestor
}
} catch {}
}
return result
}
getAttribute (classifier: Ref<Classifier>, name: string): AnyAttribute {
const attr = this.findAttribute(classifier, name)
if (attr === undefined) {
throw new Error('attribute not found: ' + name)
}
return attr
}
public findAttribute (classifier: Ref<Classifier>, name: string): AnyAttribute | undefined {
const list = [classifier]
const visited = new Set<Ref<Classifier>>()
while (list.length > 0) {
const cl = list.shift() as Ref<Classifier>
if (addNew(visited, cl)) {
const attribute = this.attributes.get(cl)?.get(name)
if (attribute !== undefined) {
return attribute
}
// Check ancestorsOf
list.push(...this.ancestorsOf(cl))
}
}View on GitHub (pinned to 63e28dc964)
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
Example fix
// before
const attr = hierarchy.getAttribute(obj._class, 'dueDate')
// after
const attr = hierarchy.findAttribute(obj._class, 'dueDate')
if (attr === undefined) {
console.warn(`Attribute dueDate missing on ${obj._class}; skipping`)
return
}
// use attr Defensive patterns
Strategy: validation
Validate before calling
const attr = hierarchy.findAttribute(classifier, name)
if (attr === undefined) {
throw new Error(`Attribute '${name}' does not exist on ${String(classifier)} or its ancestors`)
}
// safe to use attr Type guard
function hasAttribute(h: Hierarchy, c: Ref<Classifier>, name: string): boolean {
return h.findAttribute(c, name) !== undefined
} Try / catch
let attr: AnyAttribute
try {
attr = hierarchy.getAttribute(classifier, name)
} catch (err) {
console.warn(`Skipping missing attribute ${name} on ${String(classifier)}`)
return undefined
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ancestors not found: ${_class}
- class not found: ${_class}
- interface not found: ${_interface}
- domain not found: ${_class}
- descendants not found: ${_class}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/1f703af350ff5b48.
Report an issue: GitHub.