hcengineering/platform · error
Training request #${ref} not found
Error message
Training request #${ref} not found What it means
The training request title provider looks up a TrainingRequest by reference and throws when the findOne query returns undefined. Title providers must return a display string, so a missing request is an unrecoverable lookup failure. It indicates the referenced request no longer exists or the ref is wrong.
Source
Thrown at plugins/training-resources/src/functions/trainingRequestObjectTitleProvider.ts:39
export async function trainingRequestObjectTitleProvider (
client: Client,
ref: Ref<TrainingRequest>,
doc?: TrainingRequest
): Promise<string> {
const request = await client.findOne<TrainingRequest>(
training.class.TrainingRequest,
{
_id: ref
},
{
lookup: {
attachedTo: training.class.Training
}
}
)
if (request === undefined) {
throw new Error(`Training request #${ref} not found`)
}
const trainingObject = request.$lookup?.attachedTo
if (trainingObject === undefined) {
throw new Error(`Training #${request.attachedTo} not found`)
}
const revisionLabel = client.getHierarchy().getAttribute(trainingObject._class, 'revision').label
const revisionString = await translate(revisionLabel, {}, getCurrentLanguage())
return `${trainingObject.code} • ${trainingObject.title} • ${revisionString} ${trainingObject.revision}`
}
View on GitHub (pinned to 63e28dc964)
Solutions
- Confirm the TrainingRequest with that ref still exists in the current workspace.
- Purge or repair stale references (notifications, changelogs) that point to deleted requests.
- Verify the lookup query includes the correct attachedTo class and space.
- Add existence checks before resolving titles for potentially deleted objects.
Example fix
// before
const title = await trainingRequestObjectTitleProvider(client, ref)
// after
const exists = await client.findOne(training.class.TrainingRequest, { _id: ref })
const title = exists ? await trainingRequestObjectTitleProvider(client, ref) : 'deleted request' Defensive patterns
Strategy: type-guard
Validate before calling
const req = await client.findOne(training.class.TrainingRequest, { _id: ref })
if (req === undefined) return 'request unavailable' Type guard
function requestExists(r: TrainingRequest | undefined): r is TrainingRequest { return r !== undefined } Try / catch
try { return await titleProvider(client, ref) } catch { return `#${ref} (deleted)` } Prevention
- Use soft-delete so referenced requests are not hard-removed
- Purge notifications/changelogs referencing deleted requests
- Check existence before resolving display titles
When it happens
Trigger: Rendering a title for TrainingRequest #ref where no document matches the lookup (attachedTo: training.class.Training), e.g. the request was deleted or the ref points to a non-existent id.
Common situations: Stale references after request deletion; notifications/changelog entries pointing at removed requests; querying the wrong workspace/project; ids copied between environments.
Related errors
- Training #${request.attachedTo} not found
- Could not find a latest revision for training ${object.code}
- Space #${parent.space} not found
- Space type #${space.type} not found
- Sequence for ${training.class.Training} not found
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/6a5d61260a0a2c5b.
Report an issue: GitHub.