{"record":{"id":"905150d6afbb03dd","repo":"nexu-io/open-design","slug":"project-arg-omitted-and-active-context-lookup-fail","errorCode":null,"errorMessage":"project arg omitted and active context lookup failed: ${errorMessage(err)}. Pass project=\"<id-or-name>\".","messagePattern":"project arg omitted and active context lookup failed: (.+?)\\. Pass project=\"<id-or-name>\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/mcp.ts","lineNumber":2946,"sourceCode":"// When the agent omits `project`, fall back to whatever the user has\n// open in Open Design. Returns the resolved id plus, for echo-back to the\n// caller, the active-context payload that was used. Throws a clear\n// error when neither is available so the agent can prompt the user\n// rather than guessing.\nasync function resolveProjectArg(\n  baseUrl: string,\n  arg: unknown,\n  headers?: Record<string, string>,\n): Promise<{ id: string; resolved: ResolvedProject | null; active: ActiveContext | null }> {\n  if (typeof arg === 'string' && arg.length > 0) {\n    const resolved = await resolveProjectId(baseUrl, arg, headers);\n    return { id: resolved.id, resolved, active: null };\n  }\n  let active: ActiveContext;\n  try {\n    active = await getJson<ActiveContext>(`${baseUrl}/api/active`);\n  } catch (err) {\n    throw new Error(\n      `project arg omitted and active context lookup failed: ${errorMessage(err)}. Pass project=\"<id-or-name>\".`,\n    );\n  }\n  if (!active || active.active === false || !active.projectId) {\n    throw new Error(\n      'project arg omitted and Open Design has no active project. The active context expires about 5 minutes after the last user interaction with Open Design - the user may need to click into a project to wake it up. Otherwise pass project=\"<id-or-name>\".',\n    );\n  }\n  return { id: active.projectId, resolved: null, active };\n}\n\nasync function resolveProjectId(\n  baseUrl: string,\n  arg: unknown,\n  headers?: Record<string, string>,\n): Promise<ResolvedProject> {\n  if (typeof arg !== 'string' || !arg) {\n    throw new Error('project is required (string).');","sourceCodeStart":2928,"sourceCodeEnd":2964,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/mcp.ts#L2928-L2964","documentation":"Thrown by resolveProjectArg when the caller omitted `project` and the fallback GET /api/active request itself failed (non-2xx or network error). This is an infrastructure/connectivity failure, not a validation error: the daemon was unreachable, refused, or errored on the active-context endpoint. The message embeds the underlying error via errorMessage(err).","triggerScenarios":"Daemon not running; wrong base URL/port; auth/headers rejected by /api/active; daemon crashed mid-request; TLS or proxy interception on localhost; tools-dev not started.","commonSituations":"First-run without `pnpm tools-dev` started; pointing the MCP client at a stale port after a daemon restart; missing analytics/auth headers; firewall blocking the loopback port.","solutions":["Start the daemon: run `pnpm tools-dev` and confirm `pnpm tools-dev status --json` reports it healthy.","Verify the MCP base URL/port matches the running daemon's --daemon-port.","Pass `project: \"<id-or-name>\"` explicitly to bypass the /api/active lookup entirely.","Inspect the embedded errorMessage for the real HTTP status or ECONNREFUSED reason and address that.","Ensure required headers (analyticsHeaders/auth) are supplied to the MCP client."],"exampleFix":"// before\nrunStart({ prompt })  // no project, daemon down\n// after\nrunStart({ prompt, project: projectUuid })  // explicit, skips /api/active","handlingStrategy":"retry","validationCode":"async function daemonReachable(baseUrl: string): Promise<boolean> {\n  try {\n    const r = await fetch(`${baseUrl}/api/active`);\n    return r.ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runStart({ prompt });\n} catch (e) {\n  if (String(e.message).includes('active context lookup failed')) {\n    await ensureDaemonUp();  // start tools-dev, then retry\n    await runStart({ prompt, project: explicitId });\n  } else throw e;\n}","preventionTips":["Always pass an explicit project id in automation/CI.","Health-check the daemon before the first MCP call.","Keep tools-dev running for the duration of the agent task."],"tags":["mcp","network","daemon","project-resolution"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}