{"record":{"id":"e38e4694d82d78cd","repo":"hcengineering/platform","slug":"class-not-found-class","errorCode":null,"errorMessage":"class not found: ${_class}","messagePattern":"class not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/core/src/hierarchy.ts","lineNumber":198,"sourceCode":"  }\n\n  isMixin (_class: Ref<Class<Doc>>): boolean {\n    const data = this.classifiers.get(_class)\n    return data !== undefined && this._isMixin(data)\n  }\n\n  getAncestors (_class: Ref<Classifier>): Ref<Classifier>[] {\n    const result = this.ancestors.get(_class)\n    if (result === undefined) {\n      throw new Error('ancestors not found: ' + _class)\n    }\n    return result\n  }\n\n  getClass<T extends Obj = Obj>(_class: Ref<Class<T>>): Class<T> {\n    const data = this.classifiers.get(_class)\n    if (data === undefined || this.isInterface(data)) {\n      throw new Error('class not found: ' + _class)\n    }\n    return data\n  }\n\n  findClass<T extends Obj = Obj>(_class: Ref<Class<T>>): Class<T> | undefined {\n    const data = this.classifiers.get(_class)\n    if (data === undefined || this.isInterface(data)) {\n      return undefined\n    }\n    return data\n  }\n\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","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/core/src/hierarchy.ts#L180-L216","documentation":"getClass looks up a Class object in the loaded model's classifier map and throws 'class not found' when the ref is absent OR when it resolves to an interface (which is not a concrete class). It is the strict counterpart of findClass, used pervasively (spaceClass, value, ancestor, clazz, etc.).","triggerScenarios":"getClass called with: a Ref<Class> never registered in the model; a ref to an Interface instead of a Class; queries executed before model load; refs from plugins not present in the deployment.","commonSituations":"Passing an interface ref (e.g. from core.interfaces) where a class is required; typos in class refs; plugin not installed/translated so its classes never enter the model; version mismatch where a class was renamed/removed.","solutions":["Use findClass when absence is expected; reserve getClass for refs that must exist.","Confirm the ref points to a Class, not an Interface (interfaces are rejected here).","Ensure the owning plugin's model is loaded/translated before querying.","Align plugin versions between client and server so the class definition exists.","Catch the error to detect stale/unknown refs and skip or re-hydrate the object."],"exampleFix":"// before\nconst clazz = hierarchy.getClass(doc.class as Ref<Class<Doc>>)\n// after\nconst data = hierarchy.findClass(doc.class as Ref<Class<Doc>>)\nif (data === undefined) {\n  throw new Error(`Class ${doc.class} missing from loaded model`)\n}\nconst clazz = data","handlingStrategy":"type-guard","validationCode":"const data = hierarchy.findClass(_class)\nif (data === undefined) throw new Error(`Ref ${_class} not in model`)\nif (hierarchy.isInterface(data)) throw new Error(`${_class} is an interface, not a class`)","typeGuard":"function isConcreteClass(h: Hierarchy, ref: Ref<Classifier>): ref is Ref<Class<Obj>> {\n  const data = h.findClass(ref)\n  return data !== undefined && !h.isInterface(data)\n}","tryCatchPattern":"let clazz: Class<Obj>\ntry {\n  clazz = hierarchy.getClass(_class)\n} catch (err) {\n  if (err.message.startsWith('class not found')) {\n    throw new Error(`Class ${_class} missing — check plugin/model load`)\n  }\n  throw err\n}","preventionTips":["Never pass interface refs to getClass — use the interface hierarchy API instead","Use findClass when the class may not exist in the current model","Ensure plugins are translated/loaded before dependent queries","Gate model-dependent code behind an 'is model ready' check"],"tags":["model","hierarchy","typescript"],"backgroundTag":"class-not-registered","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}