hcengineering/platform · error
Model is not defined
Error message
Model is not defined
What it means
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.
Source
Thrown at pods/media/src/client.ts:211
async searchFulltext (query: SearchQuery, options: SearchOptions): Promise<SearchResult> {
return await this.client.searchFulltext(query, options)
}
async close (): Promise<void> {
// No ned to close the REST client
}
getHierarchy (): Hierarchy {
if (this.hierarchy === undefined) {
throw new Error('Hierarchy is not defined')
}
return this.hierarchy
}
getModel (): ModelDb {
if (this.model === undefined) {
throw new Error('Model is not defined')
}
return this.model
}
}
View on GitHub (pinned to 63e28dc964)
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
Example fix
// before const model = client.getModel() // after if (!client.isConnected()) await client.connect() const model = client.getModel()
Defensive patterns
Strategy: validation
Validate before calling
if (!client.isConnected?.()) await client.connect()
Try / catch
try {
const model = client.getModel()
} catch {
await client.connect()
const model = client.getModel()
} Prevention
- 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
When it happens
Trigger: Calling client.getModel() before connect() resolves, when connect() failed and left this.model unset, or when the client was closed/disposed before access.
Common situations: 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.
Related errors
- Hierarchy is not defined
- Model is not defined
- Hierarchy is not defined
- Message id is required
- Unknown content format
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/b2c07dfe65e04ffe.
Report an issue: GitHub.