{"record":{"id":"5e07fdfe9e4f9fe9","repo":"hcengineering/platform","slug":"contact-not-found-5e07fd","errorCode":null,"errorMessage":"contact not found","messagePattern":"contact not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/recruit-resources/src/components/review/CreateOpinion.svelte","lineNumber":64,"sourceCode":"\n  const dispatch = createEventDispatcher()\n  const client = getClient()\n\n  export function canClose (): boolean {\n    return review === undefined && assignee === undefined\n  }\n\n  async function createOpinion () {\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Review })\n    if (sequence === undefined) {\n      throw new Error('sequence object not found')\n    }\n\n    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)\n\n    const reviewInstance = await client.findOne(recruit.class.Review, { _id: doc.attachedTo })\n    if (reviewInstance === undefined) {\n      throw new Error('contact not found')\n    }\n\n    await client.addCollection(\n      recruit.class.Opinion,\n      reviewInstance.space,\n      doc.attachedTo,\n      doc.attachedToClass,\n      'opinions',\n      {\n        number: (incResult as any).object.sequence,\n        description: doc.description,\n        value: doc.value\n      }\n    )\n  }\n</script>\n\n<Card","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/review/CreateOpinion.svelte#L46-L82","documentation":"After incrementing the sequence, CreateOpinion.svelte fetches the parent Review document via `doc.attachedTo`. If that findOne returns undefined, the opinion cannot be attached to a review/space and the component throws — misleadingly labeled 'contact not found'. This indicates the opinion's attachedTo reference points at a review that no longer exists (or was never loaded).","triggerScenarios":"Creating an opinion from a doc whose `attachedTo` id does not resolve to a recruit.class.Review document: the review was deleted concurrently, the id is stale in the client-side cache, or the doc was created against the wrong class.","commonSituations":"Another user deleted the review while the opinion dialog was open; stale client data after offline edits; opening the dialog from a non-Review document due to a UI routing bug; permission filtering hiding the review from the current user.","solutions":["Refresh the client data and retry — the review may have been deleted or the cache is stale.","Fix the misleading message: log/throw with the actual doc.attachedTo id to debug which reference is broken.","Validate before opening the dialog that doc.attachedTo resolves to an existing Review.","Check current user's permissions — the review may exist but be invisible to this account."],"exampleFix":"// before\nconst reviewInstance = await client.findOne(recruit.class.Review, { _id: doc.attachedTo })\nif (reviewInstance === undefined) {\n  throw new Error('contact not found')\n}\n// after\nconst reviewInstance = await client.findOne(recruit.class.Review, { _id: doc.attachedTo })\nif (reviewInstance === undefined) {\n  throw new Error(`review not found: ${String(doc.attachedTo)}`)\n}","handlingStrategy":"type-guard","validationCode":"const review = await client.findOne(recruit.class.Review, { _id: doc.attachedTo })\nif (review === undefined) {\n  console.error('review missing', doc.attachedTo)\n  return\n}","typeGuard":"function reviewExists(r: Review | undefined): r is Review { return r !== undefined }","tryCatchPattern":"try {\n  await createOpinion()\n} catch (e) {\n  if (e.message === 'contact not found') {\n    await refreshClient()\n    showNotification('The review no longer exists')\n  } else throw e\n}","preventionTips":["Refresh client data before opening the opinion dialog","Re-validate doc.attachedTo on submit","Watch for concurrent review deletions (subscribe to remove events)"],"tags":["database","missing-data","stale-reference"],"backgroundTag":"referenced-document-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}