{"record":{"id":"b2c07dfe65e04ffe","repo":"hcengineering/platform","slug":"model-is-not-defined-b2c07d","errorCode":null,"errorMessage":"Model is not defined","messagePattern":"Model is not defined","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/media/src/client.ts","lineNumber":211,"sourceCode":"\n  async searchFulltext (query: SearchQuery, options: SearchOptions): Promise<SearchResult> {\n    return await this.client.searchFulltext(query, options)\n  }\n\n  async close (): Promise<void> {\n    // No ned to close the REST client\n  }\n\n  getHierarchy (): Hierarchy {\n    if (this.hierarchy === undefined) {\n      throw new Error('Hierarchy is not defined')\n    }\n    return this.hierarchy\n  }\n\n  getModel (): ModelDb {\n    if (this.model === undefined) {\n      throw new Error('Model is not defined')\n    }\n    return this.model\n  }\n}\n","sourceCodeStart":193,"sourceCodeEnd":216,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/media/src/client.ts#L193-L216","documentation":"Plain Error thrown by MediaClient.getModel when the internal model field is undefined — the same uninitialized-client family as the hierarchy error. The ModelDb is only assigned during successful connection/initialization.","triggerScenarios":"Calling client.getModel() before connect() resolves, when connect() failed and left this.model unset, or when the client was closed/disposed before access.","commonSituations":"Same as error 464: unawaited async initialization, consumers created before the connection future resolves, test harnesses instantiating without a backend, or partial failure where hierarchy connected but model assignment failed.","solutions":["Await connect()/init before calling getModel()","Check connection status at the call site or wrap access in a ready-state promise","Fix any initialization error logs that explain why this.model never got assigned","Use a factory that returns the client only after full initialization","Add integration tests asserting model availability post-connect"],"exampleFix":"// before\nconst model = client.getModel()\n// after\nif (!client.isConnected()) await client.connect()\nconst model = client.getModel()","handlingStrategy":"validation","validationCode":"if (!client.isConnected?.()) await client.connect()","typeGuard":null,"tryCatchPattern":"try {\n  const model = client.getModel()\n} catch {\n  await client.connect()\n  const model = client.getModel()\n}","preventionTips":["Await connect() before getModel()","Use a ready-promise pattern so callers queue until initialized","Log initialization failures that leave model unassigned","Cover the init-then-use path with integration tests"],"tags":["typescript","initialization","lifecycle"],"backgroundTag":"not-initialized","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}