{"record":{"id":"941c21ed6fc0b9d4","repo":"mastra-ai/mastra","slug":"project-not-found-wanted","errorCode":null,"errorMessage":"Project not found: ${wanted}","messagePattern":"Project not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/env/resolve-project.ts","lineNumber":18,"sourceCode":"import { loadProjectConfig } from '../studio/project-config.js';\nimport type { Project } from './platform-api.js';\nimport { fetchProjects } from './platform-api.js';\n\n/**\n * Resolve the target project for env-group commands without requiring a\n * positional argument. Resolution order: `MASTRA_PROJECT_ID` env var,\n * `--project` flag, then the `.mastra-project.json` written by\n * `mastra deploy` in the current directory.\n */\nexport async function resolveProject(token: string, orgId: string, projectArg?: string): Promise<Project> {\n  const projects = await fetchProjects(token, orgId);\n\n  const wanted = process.env.MASTRA_PROJECT_ID ?? projectArg;\n  if (wanted) {\n    const project = projects.find(proj => proj.id === wanted || proj.name === wanted || proj.slug === wanted);\n    if (!project) {\n      throw new Error(`Project not found: ${wanted}`);\n    }\n    return project;\n  }\n\n  const config = await loadProjectConfig(process.cwd());\n  if (config?.projectId) {\n    const project = projects.find(proj => proj.id === config.projectId);\n    if (project) return project;\n  }\n\n  throw new Error(\n    'No project specified. Pass --project <name|slug|id>, set MASTRA_PROJECT_ID, or run from a directory with a linked .mastra-project.json.',\n  );\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/env/resolve-project.ts#L1-L33","documentation":"Thrown by `resolveProject` in the `mastra env` command family when a project was explicitly requested (via --project flag or MASTRA_PROJECT_ID) but no project in the authenticated organization matches that id, name, or slug. The lookup fetches all projects for the org and requires an exact match on one of the three identifiers.","triggerScenarios":"Calling any `mastra env ...` command with `--project <value>` or MASTRA_PROJECT_ID set to a value that is not the id, name, or slug of any project in the current org (checked via fetchProjects with the auth token and org id).","commonSituations":"Typo in the project name/slug; project deleted or renamed in Mastra Cloud; MASTRA_PROJECT_ID stale in .env from another org/account; being authenticated against the wrong organization so the project isn't in the fetched list; using a display name with different casing.","solutions":["Run `mastra project list` (or check the Mastra Cloud dashboard) and copy the exact project id/name/slug, then retry","Unset or fix MASTRA_PROJECT_ID (check shell env and .env files) — `unset MASTRA_PROJECT_ID` or set the correct id","Confirm you're authenticated to the right org: re-run `mastra auth login` / verify MASTRA_ORG_ID","If the project was renamed or deleted, recreate/relink it or point at the new slug","Re-link the local directory: ensure .mastra-project.json contains a valid projectId"],"exampleFix":"// before\nmastra env vars pull --project my-projekt\n// after (exact slug from dashboard)\nmastra env vars pull --project my-project","handlingStrategy":"validation","validationCode":"import { config } from 'dotenv';\nconfig();\nconst projectId = process.env.MASTRA_PROJECT_ID;\nif (projectId && !/^prj_[A-Za-z0-9]+$/.test(projectId)) {\n  throw new Error(`MASTRA_PROJECT_ID=\"${projectId}\" does not look like a valid project id`);\n}\nif (!projectId && !process.argv.includes('--project')) {\n  throw new Error('Set MASTRA_PROJECT_ID or pass --project before running mastra env');\n}","typeGuard":"function isResolvedProject(p: unknown): p is { id: string; name: string; slug: string } {\n  return typeof p === 'object' && p !== null &&\n    typeof (p as any).id === 'string' && (p as any).id.length > 0 &&\n    typeof (p as any).slug === 'string';\n}","tryCatchPattern":"try {\n  const project = await resolveProject({ project: argv.project });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Project not found:')) {\n    console.error(`${err.message}. Run \\`mastra project list\\` for valid ids/slugs and check MASTRA_PROJECT_ID / org login.`);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Commit or template .mastra-project.json so every checkout is linked","Keep MASTRA_PROJECT_ID in per-project .env, never in global shell profile","Copy ids/slugs directly from the dashboard instead of typing names","Re-login when switching organizations to avoid looking in the wrong org","Use slugs in scripts — they are human-readable and stable across renames of ids"],"tags":["cli","config","project-lookup","mastra-cloud"],"backgroundTag":"project-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}