hcengineering/platform · error · Error

Task type not found for project: ${project.name}

Error message

Task type not found for project: ${project.name}

What it means

getIssueKind resolves the TaskType document for a project: it queries task.class.TaskType filtered by parent = project.type (when the project has a type). If no matching TaskType exists in the workspace, issue creation cannot proceed and this error is thrown with the project's name.

Source

Thrown at packages/importer/src/importer/importer.ts:857

    spaceId: Ref<Project>
  ): Promise<{ number: number, identifier: string }> {
    const incResult = await this.client.updateDoc(
      tracker.class.Project,
      core.space.Space,
      spaceId,
      { $inc: { sequence: 1 } },
      true
    )
    const number = (incResult as any).object.sequence
    const identifier = `${project.identifier}-${number}`
    return { number, identifier }
  }

  private async getIssueKind (project: Project): Promise<TaskType> {
    const taskKind = project?.type !== undefined ? { parent: project.type } : {}
    const kind = await this.client.findOne(task.class.TaskType, taskKind)
    if (kind === undefined) {
      throw new Error(`Task type not found for project: ${project.name}`)
    }
    return kind
  }

  private async getIssueRank (project: Project, spaceId: Ref<Project>): Promise<string> {
    const lastIssue = await this.client.findOne<Issue>(
      tracker.class.Issue,
      { space: spaceId },
      { sort: { rank: SortingOrder.Descending } }
    )
    return makeRank(lastIssue?.rank, undefined)
  }

  private async importComments (issueId: Ref<Issue>, comments: ImportComment[], projectId: Ref<Project>): Promise<void> {
    const sortedComments = comments.sort((a, b) => {
      const now = Date.now()
      return (a.date ?? now) - (b.date ?? now)
    })

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Ensure the target workspace has TaskTypes registered under the project's type before importing issues (run the task-type seeding/create step first)
  2. Check that project.type is set on the imported Project and matches an existing ProjectType in the workspace
  3. Verify built-in TaskTypes exist (query task.class.TaskType directly) — if missing, re-run workspace initialization
  4. Align importer and server versions so default ProjectType/TaskType definitions match

Example fix

// before
const project = { ...project, type: undefined } // falls into taskKind = {}
// after
const projectType = await client.findOne(core.class.Type, { name: 'Bug Project' })
const project = { ...project, type: projectType._id } // TaskTypes seeded under this type
Defensive patterns

Strategy: validation

Validate before calling

async function ensureTaskTypes(client, project) {
  const kind = await client.findOne(task.class.TaskType,
    project.type !== undefined ? { parent: project.type } : {})
  if (kind === undefined) {
    throw new Error(`Workspace has no TaskType for project type: ${String(project.type)}`)
  }
}

Type guard

function hasProjectType(p: Project): p is Project & { type: Ref<ProjectType> } {
  return p.type !== undefined
}

Try / catch

try {
  await importer.importIssues(project, issues)
} catch (err) {
  if (err.message.startsWith('Task type not found')) {
    console.error('Seed TaskTypes in the target workspace before importing:', err.message)
  } else throw err
}

Prevention

When it happens

Trigger: project.type is undefined (query falls back to {} and either finds nothing or an unexpected default), or project.type references a ProjectType whose TaskType children were never created/imported in the target workspace.

Common situations: Importing into a workspace where the ProjectType was created without its TaskTypes; target workspace from an older/newer version with different built-in task types; partial import where TaskType creation step failed or was skipped.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/cb6e3d132b699cd8. Report an issue: GitHub.