nexu-io/open-design · error · Error

Project ${projectId} not found

Error message

Project ${projectId} not found

What it means

Thrown by resolveProjectShareDir when the `project` argument is null or undefined. The function resolves a project's share directory by delegating to resolveProjectDir with the project's metadata, so it needs an actual project object; a missing project is treated as a programmer error rather than silently producing a path. The projectId is echoed for diagnostics.

Source

Thrown at apps/daemon/src/collab/project-share-dir.ts:7

export function resolveProjectShareDir(
  projectsRoot: string,
  projectId: string,
  project: { id: string; metadata?: unknown } | null | undefined,
  resolveProjectDir: (projectsRoot: string, projectId: string, metadata?: unknown) => string,
): string {
  if (!project) throw new Error(`Project ${projectId} not found`);
  return resolveProjectDir(projectsRoot, projectId, project.metadata);
}

View on GitHub (pinned to 5be4028344)

Solutions

  1. Handle the not-found case at the lookup site before calling resolveProjectShareDir.
  2. Verify the projectId is correct and the project still exists.
  3. Return a 404 or equivalent upstream instead of forwarding a null project to this function.

Example fix

// before
const project = await findProject(id);
const dir = resolveProjectShareDir(root, id, project, resolveDir);
// after
const project = await findProject(id);
if (!project) throw new NotFoundError(`project ${id} not found`);
const dir = resolveProjectShareDir(root, id, project, resolveDir);
Defensive patterns

Strategy: validation

Validate before calling

function ensureProjectThenShareDir(projectsRoot, projectId, lookup, resolveProjectDir) {
  const project = lookup(projectId);
  if (!project) throw new Error(`Project ${projectId} not found`);
  return resolveProjectShareDir(projectsRoot, projectId, project, resolveProjectDir);
}

Type guard

function hasProject(value: unknown): value is { id: string; metadata?: unknown } {
  return Boolean(value) && typeof value === 'object' && typeof (value as { id?: unknown }).id === 'string';
}

Try / catch

try {
  return resolveProjectShareDir(root, projectId, project, resolveDir);
} catch (err) {
  if (err instanceof Error && /Project .* not found/.test(err.message)) {
    // return 404 upstream instead of crashing the request
  }
  throw err;
}

Prevention

When it happens

Trigger: A caller that looked up a project by id, got null back (not found / deleted), and then passed that null straight into resolveProjectShareDir.

Common situations: A race where the project is deleted between the lookup and the share-dir resolution, a wrong/mistyped project id, or a caller that forgot to handle the not-found case from its own lookup.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/e821bf17a3c4cc1a. Report an issue: GitHub.