hcengineering/platform · error · Error
Project not found: ${projectId}
Error message
Project not found: ${projectId} What it means
importProject first finds or creates the project, then re-reads it from the backing store with client.findOne(tracker.class.Project, {_id: projectId}). If the document is not found even after creation, the store is inconsistent and the importer aborts with 'Project not found: <id>'.
Source
Thrown at packages/importer/src/importer/importer.ts:469
return id
}
async importProject (project: ImportProject): Promise<Ref<Project>> {
let projectId: Ref<Project>
if (project.id === tracker.project.DefaultProject) {
this.logger.log('Setting up default project: ' + project.title)
projectId = tracker.project.DefaultProject
await this.updateProject(projectId, project)
this.logger.log('Default project updated: ' + projectId)
} else {
this.logger.log('Creating project: ', project.title)
projectId = await this.createProject(project)
this.logger.log('Project created: ' + projectId)
}
const projectDoc = await this.client.findOne(tracker.class.Project, { _id: projectId })
if (projectDoc === undefined) {
throw new Error('Project not found: ' + projectId)
}
// Create Component / Milestone docs declared on the
// project. The maps keep them addressable by label for later
// resolution from issue front-matter.
const componentIds = new Map<string, Ref<any>>()
const milestoneIds = new Map<string, Ref<any>>()
if (project.components !== undefined) {
for (const c of project.components) {
const id = generateId()
await this.client.createDoc(
tracker.class.Component,
projectId,
{
label: c.label,
description: c.description ?? '',
lead: null,
comments: 0,View on GitHub (pinned to 63e28dc964)
Solutions
- Verify the projectId comes from the same workspace the client is connected to
- Confirm the project still exists in the target workspace before importing (findOne yourself)
- If createProject returned an id, check server logs for a failed/persisted create transaction
- Delete stale import state and re-run the import from scratch so projects are recreated
Example fix
// before
await importer.importProject('nonexistent-project-id' as Ref<Project>, project)
// after
const existing = await client.findOne(tracker.class.Project, { _id: projectId })
if (existing === undefined) {
projectId = await importer.importProject(undefined, project) // let it create
} Defensive patterns
Strategy: validation
Validate before calling
const existing = await client.findOne(tracker.class.Project, { _id: projectId })
if (existing === undefined) {
throw new Error(`Refusing to import: project ${projectId} does not exist in this workspace`)
} Type guard
function projectRef(v: unknown): v is Ref<Project> {
return typeof v === 'string' && v.length > 0
} Try / catch
try {
await importer.importProject(projectId, project)
} catch (err) {
if (err.message.startsWith('Project not found:')) {
// recreate then retry
await importer.importProject(undefined, project)
} else throw err
} Prevention
- Always fetch project ids fresh from the connected workspace instead of caching across runs
- Confirm client connection/workspace matches the ids you pass
- Never assume createProject persisted — verify with findOne before continuing
- Avoid deleting target projects between incremental import runs
When it happens
Trigger: client.findOne returns undefined for the projectId — the project was deleted between creation and lookup, the projectId passed to importProject never existed (stale/wrong Ref), or createProject silently failed while still returning an id.
Common situations: Rerunning a partially completed import against a workspace where the project was later removed; passing a projectId string that refers to a project in a different workspace; permissions/db replication lag in a distributed backend.
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
- Unsupported card type: ${cardType} in ${cardPath}
- Invalid master tag data
- Invalid tag data
- Unsupported type: ${property.type} ${currentPath}
- Blob file not found: ${blobPath} from:${cardPath}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/04c606abcdf4d1e4.
Report an issue: GitHub.