hcengineering/platform · error · Error
domain not found: ${_class}
Error message
domain not found: ${_class} What it means
Hierarchy.getDomain determines which model domain (e.g. model, task, contact) a class belongs to by walking ancestors via findDomain. If no ancestor has a registered domain, it throws 'domain not found'. It indicates the class (or its ancestors) is not registered in the hierarchy, so its domain cannot be inferred.
Source
Thrown at foundations/core/packages/core/src/hierarchy.ts:236
const data = this.classifiers.get(_class)
if (data === undefined) {
throw new Error('class not found: ' + _class)
}
return data
}
getInterface (_interface: Ref<Interface<Doc>>): Interface<Doc> {
const data = this.classifiers.get(_interface)
if (data === undefined || !this.isInterface(data)) {
throw new Error('interface not found: ' + _interface)
}
return data
}
getDomain (_class: Ref<Class<Obj>>): Domain {
const domain = this.findDomain(_class)
if (domain === undefined) {
throw new Error(`domain not found: ${_class} `)
}
return domain
}
public findDomain (_class: Ref<Class<Doc>>): Domain | undefined {
const klazz = this.findClass(_class)
if (klazz === undefined) return
if (klazz.domain !== undefined) {
return klazz.domain
}
let _klazz: Class<Doc> | undefined = klazz
while (_klazz.extends !== undefined) {
_klazz = this.findClass(_klazz.extends)
if (_klazz === undefined) return
if (_klazz.domain !== undefined) {
// Cache for next requests
klazz.domain = _klazz.domainView on GitHub (pinned to 63e28dc964)
Solutions
- Apply the class's model tx to the hierarchy before calling getDomain
- Confirm the class ref is spelled correctly and its plugin model is loaded
- Use findDomain(...) !== undefined as a guard when the class may be unregistered
- Check the class derives from an ancestor that carries the domain registration
Example fix
// before
const domain = hierarchy.getDomain(myClass)
// after
const domain = hierarchy.findDomain(myClass)
if (domain === undefined) throw new Error(`Class ${myClass} is not registered in hierarchy`)
// then use domain
return domain Defensive patterns
Strategy: validation
Validate before calling
const domain = hierarchy.findDomain(_class)
if (domain === undefined) {
throw new Error(`No domain registered for class ${String(_class)}`)
}
// safe to use domain Type guard
function hasDomain(h: Hierarchy, c: Ref<Class<Doc>>): boolean {
return h.findDomain(c) !== undefined
} Try / catch
let domain: Domain
try {
domain = hierarchy.getDomain(_class)
} catch (err) {
console.error(`Cannot resolve domain for ${String(_class)}`, err)
throw err
} Prevention
- Ensure every custom class derives from an ancestor carrying a domain
- Run getDomain-dependent code only after full model sync/upgrades
- Prefer findDomain + explicit undefined handling in library-like code
- Check class refs against the installed plugin set
When it happens
Trigger: Calling getDomain/domain/baseDomain with an unregistered class ref; calling during fixMixinForeignAttributes or updateField before the class model tx is applied; typos in class refs.
Common situations: Upgrade scripts running before model txes are pushed; client-side hierarchy missing the plugin model; a new class created without adding it to a domain's hierarchy ancestors.
Related errors
- interface not found: ${_interface}
- descendants not found: ${_class}
- ancestors not found: ${_class}
- class not found: ${_class}
- attribute not found: ${name}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/b6e4a612573fdbec.
Report an issue: GitHub.