{"record":{"id":"d6185882c4631eb4","repo":"hcengineering/platform","slug":"contact-not-found-d61858","errorCode":null,"errorMessage":"contact not found","messagePattern":"contact not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/recruit-resources/src/components/CreateApplication.svelte","lineNumber":133,"sourceCode":"  }\n\n  async function createApplication (): Promise<void> {\n    if (selectedState === undefined) {\n      throw new Error(`Please select initial state:${_space}`)\n    }\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: recruit.class.Applicant })\n    if (sequence === undefined) {\n      throw new Error('sequence object not found')\n    }\n    if (kind === undefined) {\n      throw new Error('kind is not specified')\n    }\n\n    const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)\n\n    const candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })\n    if (candidateInstance === undefined) {\n      throw new Error('contact not found')\n    }\n\n    const ops = client.apply(undefined, recruitId + '.Create.CreateApplication')\n\n    if (!client.getHierarchy().hasMixin(candidateInstance, recruit.mixin.Candidate)) {\n      await ops.createMixin<Contact, Candidate>(\n        candidateInstance._id,\n        candidateInstance._class,\n        candidateInstance.space,\n        recruit.mixin.Candidate,\n        {}\n      )\n    }\n\n    const number = (incResult as any).object.sequence\n\n    await ops.addCollection(\n      recruit.class.Applicant,","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/recruit-resources/src/components/CreateApplication.svelte#L115-L151","documentation":"Thrown in CreateApplication.svelte when the candidate lookup fails: client.findOne(contact.class.Person, {_id: _candidate}) returns undefined. The Person instance is required to check/apply the recruit.mixin.Candidate mixin and link the application.","triggerScenarios":"_candidate holds a Ref<Person> that does not resolve: candidate deleted before submission, invalid id passed into the dialog, or client not synced with the workspace containing that person.","commonSituations":"Candidate removed by another user while the application dialog is open; stale list data; wrong ref type passed (Contact vs Person) so lookup misses.","solutions":["Re-select the candidate in the dialog and retry","Confirm the person exists via client.findOne before opening the application form","Refresh client data / reconnect to sync deletions","Catch the error and ask the user to pick a different candidate"],"exampleFix":"// before\nconst candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })\nif (candidateInstance === undefined) {\n  throw new Error('contact not found')\n}\n// after\nif (_candidate === undefined) return\nconst candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })\nif (candidateInstance === undefined) {\n  ui.notify('Selected candidate no longer exists. Please choose another person.')\n  return\n}","handlingStrategy":"validation","validationCode":"if (_candidate === undefined) return\nconst person = await client.findOne(contact.class.Person, { _id: _candidate })\nif (person === undefined) {\n  ui.notify('Candidate not found; please reselect.')\n  return\n}","typeGuard":"function isPerson (p: Person | undefined): p is Person {\n  return p !== undefined\n}","tryCatchPattern":"try {\n  await createApplication()\n} catch (err) {\n  if (err instanceof Error && err.message === 'contact not found') {\n    ui.notify('The selected candidate was deleted. Pick another one.')\n  } else throw err\n}","preventionTips":["Re-check the candidate exists immediately before submit","Subscribe to removal events to invalidate stale candidate refs","Pass Ref<Person> values from typed sources only","Refresh candidate lists after bulk deletions"],"tags":["reference-lookup","deleted-object","recruit"],"backgroundTag":"referenced-object-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}