{"record":{"id":"6a5d61260a0a2c5b","repo":"hcengineering/platform","slug":"training-request-ref-not-found","errorCode":null,"errorMessage":"Training request #${ref} not found","messagePattern":"Training request #(.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/training-resources/src/functions/trainingRequestObjectTitleProvider.ts","lineNumber":39,"sourceCode":"\nexport async function trainingRequestObjectTitleProvider (\n  client: Client,\n  ref: Ref<TrainingRequest>,\n  doc?: TrainingRequest\n): Promise<string> {\n  const request = await client.findOne<TrainingRequest>(\n    training.class.TrainingRequest,\n    {\n      _id: ref\n    },\n    {\n      lookup: {\n        attachedTo: training.class.Training\n      }\n    }\n  )\n  if (request === undefined) {\n    throw new Error(`Training request #${ref} not found`)\n  }\n  const trainingObject = request.$lookup?.attachedTo\n  if (trainingObject === undefined) {\n    throw new Error(`Training #${request.attachedTo} not found`)\n  }\n\n  const revisionLabel = client.getHierarchy().getAttribute(trainingObject._class, 'revision').label\n  const revisionString = await translate(revisionLabel, {}, getCurrentLanguage())\n  return `${trainingObject.code} • ${trainingObject.title} • ${revisionString} ${trainingObject.revision}`\n}\n","sourceCodeStart":21,"sourceCodeEnd":50,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/training-resources/src/functions/trainingRequestObjectTitleProvider.ts#L21-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"Stale references after request deletion; notifications/changelog entries pointing at removed requests; querying the wrong workspace/project; ids copied between environments.","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."],"exampleFix":"// before\nconst title = await trainingRequestObjectTitleProvider(client, ref)\n// after\nconst exists = await client.findOne(training.class.TrainingRequest, { _id: ref })\nconst title = exists ? await trainingRequestObjectTitleProvider(client, ref) : 'deleted request'","handlingStrategy":"type-guard","validationCode":"const req = await client.findOne(training.class.TrainingRequest, { _id: ref })\nif (req === undefined) return 'request unavailable'","typeGuard":"function requestExists(r: TrainingRequest | undefined): r is TrainingRequest { return r !== undefined }","tryCatchPattern":"try { return await titleProvider(client, ref) } catch { return `#${ref} (deleted)` }","preventionTips":["Use soft-delete so referenced requests are not hard-removed","Purge notifications/changelogs referencing deleted requests","Check existence before resolving display titles"],"tags":["lookup","missing-object","training"],"backgroundTag":"referenced-object-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}