{"record":{"id":"d78d0ddd104753c5","repo":"hcengineering/platform","slug":"no-project-type-found","errorCode":null,"errorMessage":"No project type found","messagePattern":"No project type found","errorType":"exception","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"plugins/task/src/utils.ts","lineNumber":262,"sourceCode":"  // TODO: not needed ???\n  await client.createMixin(targetProjectClassId, core.class.Mixin, core.space.Model, task.mixin.ProjectTypeClass, {\n    projectType: _id\n  })\n\n  return tmpl\n}\n\n/**\n * @public\n */\nexport async function updateProjectType (\n  client: TxOperations,\n  projectType: Ref<ProjectType>,\n  tasks: TaskTypeWithFactory[]\n): Promise<void> {\n  const current = await client.findOne(task.class.ProjectType, { _id: projectType })\n  if (current === undefined) {\n    throw new PlatformError(unknownStatus('No project type found'))\n  }\n\n  const _tasks: Ref<TaskType>[] = [...current.tasks]\n  const tasksData = new Map<Ref<TaskType>, Data<TaskType>>()\n  const _statues = new Set<Ref<Status>>()\n\n  const hasUpdates = await createTaskTypes(tasks, projectType, client, _statues, tasksData, _tasks, true)\n\n  if (hasUpdates) {\n    const ttypes = await client.findAll<TaskType>(task.class.TaskType, { _id: { $in: _tasks } })\n    const newStatuses = calculateStatuses(\n      {\n        statuses: current.statuses,\n        tasks: _tasks\n      },\n      new Map(ttypes.map((it) => [it._id, it])),\n      []\n    )","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/task/src/utils.ts#L244-L280","documentation":"updateProjectType first loads the existing ProjectType by id via client.findOne; if it is missing the code throws a PlatformError wrapping unknownStatus('No project type found'). This is a deliberate not-found signal (not a crash), meaning the caller passed a projectType Ref that doesn't exist in the database.","triggerScenarios":"Calling updateProjectType with a stale or deleted Ref<ProjectType>; passing an id from another workspace/db; a race where the project type was deleted between listing and updating.","commonSituations":"UI holding an outdated project type after concurrent deletion; hardcoded ids in scripts/tests; cross-tenant data mixing.","solutions":["Re-fetch the project type (client.findOne(task.class.ProjectType, { _id })) and handle undefined before updating","Verify the Ref comes from the same workspace/connection you're updating against","If deletion is concurrent, catch the PlatformError and inform the user the type no longer exists","Check for id typos by listing existing ProjectTypes and matching by name"],"exampleFix":"// before\nawait updateProjectType(client, maybeDeletedId, tasks) // throws if gone\n// after\nconst pt = await client.findOne(task.class.ProjectType, { _id: maybeDeletedId })\nif (pt === undefined) {\n  console.warn('Project type no longer exists, skipping update')\n  return\n}\nawait updateProjectType(client, pt._id, tasks)","handlingStrategy":"validation","validationCode":"const current = await client.findOne(task.class.ProjectType, { _id: projectType })\nif (current === undefined) {\n  // skip or recreate; do not call updateProjectType\n  return\n}\nawait updateProjectType(client, projectType, tasks)","typeGuard":"async function projectTypeExists (client: TxOperations, id: Ref<ProjectType>): Promise<boolean> {\n  return (await client.findOne(task.class.ProjectType, { _id: id })) !== undefined\n}","tryCatchPattern":"try {\n  await updateProjectType(client, projectType, tasks)\n} catch (err) {\n  if (err instanceof PlatformError && err.message.includes('No project type found')) {\n    console.warn('Project type was deleted; skipping update', projectType)\n    return\n  }\n  throw err\n}","preventionTips":["Re-check existence right before updates in long-running flows","Never hardcode ProjectType ids in scripts; look them up by identifier","Handle concurrent deletion gracefully in UI code that holds stale references"],"tags":["not-found","stale-reference","project-type"],"backgroundTag":"entity-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}