{"record":{"id":"775a72d81d0c8781","repo":"hcengineering/platform","slug":"interface-not-found-interface","errorCode":null,"errorMessage":"interface not found: ${_interface}","messagePattern":"interface not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/core/src/hierarchy.ts","lineNumber":228,"sourceCode":"\n  hasClass<T extends Obj = Obj>(_class: Ref<Class<T>>): boolean {\n    const data = this.classifiers.get(_class)\n\n    return !(data === undefined || this.isInterface(data))\n  }\n\n  getClassOrInterface (_class: Ref<Class<Obj>>): Class<Obj> {\n    const data = this.classifiers.get(_class)\n    if (data === undefined) {\n      throw new Error('class not found: ' + _class)\n    }\n    return data\n  }\n\n  getInterface (_interface: Ref<Interface<Doc>>): Interface<Doc> {\n    const data = this.classifiers.get(_interface)\n    if (data === undefined || !this.isInterface(data)) {\n      throw new Error('interface not found: ' + _interface)\n    }\n    return data\n  }\n\n  getDomain (_class: Ref<Class<Obj>>): Domain {\n    const domain = this.findDomain(_class)\n    if (domain === undefined) {\n      throw new Error(`domain not found: ${_class} `)\n    }\n    return domain\n  }\n\n  public findDomain (_class: Ref<Class<Doc>>): Domain | undefined {\n    const klazz = this.findClass(_class)\n    if (klazz === undefined) return\n    if (klazz.domain !== undefined) {\n      return klazz.domain\n    }","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/core/src/hierarchy.ts#L210-L246","documentation":"Hierarchy.getInterface resolves an interface Ref from the classifiers map and additionally verifies the resolved classifier is actually an Interface. It throws if the ref is unregistered OR resolves to a Class instead of an Interface. This guards against passing a class ref where an interface ref is expected.","triggerScenarios":"Calling getInterface (e.g. from withStateInterface) with a ref not present in classifiers, or with a Ref<Class> mistakenly used as an interface, or before the interface's model tx has been added to the hierarchy.","commonSituations":"Confusing core.class.X with core.interface.X (they are sibling refs); interfaces defined in a plugin that is not loaded; applying interface txes out of order so withStateInterface runs before registration.","solutions":["Verify you are using the interface Ref (core.interface.X / plugin.interface.X), not the class Ref","Ensure the Interface classifier tx was applied to the hierarchy before the call","Check the plugin defining the interface is installed and its model loaded","Use findAttribute/isInterface checks beforehand if the interface may legitimately be missing"],"exampleFix":"// before\nconst iface = hierarchy.getInterface(someRef) // someRef is a class ref\n// after\nconst iface = hierarchy.getInterface(core.interface.ClassDoc) // correct interface ref","handlingStrategy":"validation","validationCode":"if (hierarchy.findClass(_interface) === undefined || !hierarchy.isInterface(hierarchy.getClass(_interface))) {\n  throw new Error(`${String(_interface)} is not a registered interface`)\n}\nconst iface = hierarchy.getInterface(_interface)","typeGuard":"function isRegisteredInterface(h: Hierarchy, r: Ref<Interface<Doc>>): boolean {\n  const c = h.findClass(r)\n  return c !== undefined && h.isInterface(c)\n}","tryCatchPattern":"let iface: Interface<Doc>\ntry {\n  iface = hierarchy.getInterface(ref)\n} catch (err) {\n  console.warn(`Interface ${String(ref)} not registered or is a class`)\n  throw err\n}","preventionTips":["Distinguish core.interface.X from core.class.X refs when coding","Register interface classifiers before any withStateInterface usage","Verify plugin models defining interfaces are installed","Add unit checks that interface refs resolve via isInterface"],"tags":["hierarchy","interface","missing-classifier"],"backgroundTag":"classifier-not-registered","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}