{"record":{"id":"fd4861141d283354","repo":"hcengineering/platform","slug":"kind-is-not-specified-fd4861","errorCode":null,"errorMessage":"kind is not specified","messagePattern":"kind is not specified","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/lead-resources/src/components/CreateLead.svelte","lineNumber":92,"sourceCode":"  }\n\n  $: if (_space === undefined) {\n    if (funnels.find((it) => it._id === _space) === undefined) {\n      _space = funnels[0]?._id\n    }\n  }\n\n  $: funnel = funnels.find((it) => it._id === _space)\n\n  let kind: Ref<TaskType> | undefined = undefined\n\n  async function createLead () {\n    const sequence = await client.findOne(core.class.Sequence, { attachedTo: lead.class.Lead })\n    if (sequence === undefined || customer == null) {\n      throw new Error('Lead  creation failed')\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    const number = (incResult as any).object.sequence\n\n    const value: AttachedData<Lead> = {\n      status: state,\n      number,\n      identifier: `LEAD-${number}`,\n      title,\n      kind,\n      rank: '',\n      assignee: null,\n      startDate: null,\n      dueDate: null,\n      ...object\n    }\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/lead-resources/src/components/CreateLead.svelte#L74-L110","documentation":"Thrown in CreateLead.svelte when the `kind` variable (Ref<TaskType>) is still undefined at creation time. The Lead requires a kind/task-type reference to be assigned, and the code refuses to create the lead without one.","triggerScenarios":"User submits the CreateLead form without picking a kind from the selector, or the kinds list failed to load leaving `kind` undefined even after an attempted selection.","commonSituations":"TaskType documents not seeded in the workspace so the dropdown is empty; UI allows submit while kind selector is untouched; event binding failure leaving the variable unset.","solutions":["Choose a kind in the dialog before clicking create","Disable the submit button until `kind` is set (validate in canClose or form logic)","Ensure lead TaskType objects exist and are loaded (run plugin seed/migration)","Catch the error and prompt the user to select a kind"],"exampleFix":"// before\nif (kind === undefined) {\n  throw new Error('kind is not specified')\n}\n// after\nif (kind === undefined) {\n  ui.notify('Please select a lead kind before creating')\n  return\n}","handlingStrategy":"validation","validationCode":"if (kind === undefined) {\n  ui.notify('Kind is required')\n  return\n}\nawait createLead()","typeGuard":"function hasKind (kind: Ref<TaskType> | undefined): kind is Ref<TaskType> {\n  return kind !== undefined\n}","tryCatchPattern":"try {\n  await createLead()\n} catch (err) {\n  if (err instanceof Error && err.message === 'kind is not specified') {\n    ui.notify('Please pick a lead kind and try again.')\n  } else throw err\n}","preventionTips":["Disable submit until all required selectors are filled","Validate in canClose() before allowing dialog close-and-create","Ensure TaskType docs are seeded so the kind dropdown is never empty","Add a default kind when only one option exists"],"tags":["validation","missing-selection","lead"],"backgroundTag":"required-field-missing","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}