{"record":{"id":"ce1db416bc50232b","repo":"hcengineering/platform","slug":"project-projectpath-not-found","errorCode":null,"errorMessage":"Project ${projectPath} not found","messagePattern":"Project (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/importer/src/importer/builder.ts","lineNumber":108,"sourceCode":"\n  addProject (path: string, project: ImportProject): this {\n    this.validateAndAdd('project', path, project, (p) => this.validateProject(p), this.projects, path)\n    return this\n  }\n\n  addTeamspace (path: string, teamspace: ImportTeamspace): this {\n    this.validateAndAdd('teamspace', path, teamspace, (t) => this.validateTeamspace(t), this.teamspaces, path)\n    return this\n  }\n\n  addIssue (projectPath: string, issuePath: string, issue: ImportIssue, parentIssuePath?: string): this {\n    if (!this.issuesByProject.has(projectPath)) {\n      this.issuesByProject.set(projectPath, new Map())\n    }\n\n    const projectIssues = this.issuesByProject.get(projectPath)\n    if (projectIssues === undefined) {\n      throw new Error(`Project ${projectPath} not found`)\n    }\n\n    const duplicateIssue = Array.from(projectIssues.values()).find(\n      (existingIssue) => existingIssue.number === issue.number\n    )\n\n    if (duplicateIssue !== undefined) {\n      this.addError(issuePath, `Duplicate issue number ${issue.number} in project ${projectPath}`)\n    } else {\n      this.validateAndAdd('issue', issuePath, issue, (i) => this.validateIssue(i), projectIssues, issuePath)\n\n      if (parentIssuePath !== undefined) {\n        this.issueParents.set(issuePath, parentIssuePath)\n      }\n    }\n    return this\n  }\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/importer/builder.ts#L90-L126","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call addProject(projectPath, ...) for the project before adding issues to it so ordering is well defined.","Do not share or mutate the WorkspaceBuilder across concurrent tasks; process issues sequentially per builder instance.","Check for subclass/custom code that clears or replaces the builder's internal maps during import.","If the error persists, file a bug: the invariant should be unreachable."],"exampleFix":"// before\nbuilder.addIssue('proj/unknown', issuePath, issue)\n// after\nbuilder.addProject('proj/unknown', project)\nbuilder.addIssue('proj/unknown', issuePath, issue)","handlingStrategy":"try-catch","validationCode":"if (!builder.getProjects().has(projectPath)) {\n  builder.addProject(projectPath, project)\n}","typeGuard":null,"tryCatchPattern":"try {\n  builder.addIssue(projectPath, issuePath, issue)\n} catch (e) {\n  if ((e as Error).message === `Project ${projectPath} not found`) {\n    console.error(`Builder state lost for project ${projectPath}; re-create builder and re-add project first`)\n  } else throw e\n}","preventionTips":["Always addProject before addIssue for a given path.","Use one WorkspaceBuilder per import run; never share across concurrent tasks.","Do not clear or rebuild builder internals mid-import.","Treat this error as a state-corruption signal: restart the import from scratch."],"tags":["importer","builder","invariant","state"],"backgroundTag":"internal-state-invariant","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}