hcengineering/platform · error · Error

Project ${projectPath} not found

Error message

Project ${projectPath} not found

What it means

WorkspaceBuilder.addIssue stores issues per project in this.issuesByProject, creating the inner Map if absent. The subsequent get() returning undefined is treated as an internal invariant violation and throws 'Project <path> not found'. Under normal use this is unreachable because the map is created two lines earlier; it is a defensive check against concurrent mutation or corrupted state.

Source

Thrown at packages/importer/src/importer/builder.ts:108

  addProject (path: string, project: ImportProject): this {
    this.validateAndAdd('project', path, project, (p) => this.validateProject(p), this.projects, path)
    return this
  }

  addTeamspace (path: string, teamspace: ImportTeamspace): this {
    this.validateAndAdd('teamspace', path, teamspace, (t) => this.validateTeamspace(t), this.teamspaces, path)
    return this
  }

  addIssue (projectPath: string, issuePath: string, issue: ImportIssue, parentIssuePath?: string): this {
    if (!this.issuesByProject.has(projectPath)) {
      this.issuesByProject.set(projectPath, new Map())
    }

    const projectIssues = this.issuesByProject.get(projectPath)
    if (projectIssues === undefined) {
      throw new Error(`Project ${projectPath} not found`)
    }

    const duplicateIssue = Array.from(projectIssues.values()).find(
      (existingIssue) => existingIssue.number === issue.number
    )

    if (duplicateIssue !== undefined) {
      this.addError(issuePath, `Duplicate issue number ${issue.number} in project ${projectPath}`)
    } else {
      this.validateAndAdd('issue', issuePath, issue, (i) => this.validateIssue(i), projectIssues, issuePath)

      if (parentIssuePath !== undefined) {
        this.issueParents.set(issuePath, parentIssuePath)
      }
    }
    return this
  }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Call addProject(projectPath, ...) for the project before adding issues to it so ordering is well defined.
  2. Do not share or mutate the WorkspaceBuilder across concurrent tasks; process issues sequentially per builder instance.
  3. Check for subclass/custom code that clears or replaces the builder's internal maps during import.
  4. If the error persists, file a bug: the invariant should be unreachable.

Example fix

// before
builder.addIssue('proj/unknown', issuePath, issue)
// after
builder.addProject('proj/unknown', project)
builder.addIssue('proj/unknown', issuePath, issue)
Defensive patterns

Strategy: try-catch

Validate before calling

if (!builder.getProjects().has(projectPath)) {
  builder.addProject(projectPath, project)
}

Try / catch

try {
  builder.addIssue(projectPath, issuePath, issue)
} catch (e) {
  if ((e as Error).message === `Project ${projectPath} not found`) {
    console.error(`Builder state lost for project ${projectPath}; re-create builder and re-add project first`)
  } else throw e
}

Prevention

When it happens

Trigger: Calling addIssue with a projectPath after the builder's issuesByProject map was externally cleared/corrupted, or in a race where the entry is removed between set and get. In normal sequential code this throw cannot fire because addIssue creates the entry first.

Common situations: Sharing a single WorkspaceBuilder across concurrent async tasks that reset builder state; custom subclass overriding map handling; rebuilding the builder mid-import while issue processing is in flight.

Related errors


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