{"record":{"id":"a6b21211ce5a717e","repo":"mastra-ai/mastra","slug":"linked-studio-project-linkedprojectid-was-not-f","errorCode":null,"errorMessage":"Linked Studio project ${linkedProjectId} was not found in this organization. Re-link your project or pass a deploy ID explicitly.","messagePattern":"Linked Studio project (.+?) was not found in this organization\\. Re-link your project or pass a deploy ID explicitly\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/studio/deploy-suggestions.ts","lineNumber":23,"sourceCode":"import { pollForDiagnosis, printDeploySuggestions } from '../deploy-suggestions.js';\nimport { fetchDeployDiagnosis, fetchProjects, startDeployDiagnosis } from './platform-api.js';\nimport type { Project } from './platform-api.js';\nimport { loadProjectConfig } from './project-config.js';\n\nfunction getLatestProjectDeploy(projects: Project[], linkedProjectId?: string) {\n  const linkedProject = linkedProjectId ? projects.find(project => project.id === linkedProjectId) : null;\n  if (linkedProject) {\n    if (linkedProject.latestDeployId) {\n      return { deployId: linkedProject.latestDeployId, projectId: linkedProject.id, projectName: linkedProject.name };\n    }\n\n    throw new Error(\n      `No deploys found for linked Studio project ${linkedProject.name}. The suggestions command helps debug failed deployments, and you can run it after a deployment fails with \\`mastra studio deploy suggestions <deploy-id>\\` or \\`mastra studio deploy suggestions\\`.`,\n    );\n  }\n\n  if (linkedProjectId) {\n    throw new Error(\n      `Linked Studio project ${linkedProjectId} was not found in this organization. Re-link your project or pass a deploy ID explicitly.`,\n    );\n  }\n\n  const latestProject = projects\n    .filter(project => project.latestDeployId)\n    .sort((left, right) => {\n      const leftTime = left.latestDeployCreatedAt ? Date.parse(left.latestDeployCreatedAt) : 0;\n      const rightTime = right.latestDeployCreatedAt ? Date.parse(right.latestDeployCreatedAt) : 0;\n      return rightTime - leftTime;\n    })[0];\n\n  if (!latestProject?.latestDeployId) {\n    return null;\n  }\n\n  return { deployId: latestProject.latestDeployId, projectId: latestProject.id, projectName: latestProject.name };\n}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy-suggestions.ts#L5-L41","documentation":"Thrown by getLatestProjectDeploy when the Studio config references a linked project ID that does not exist among the projects fetched for the current organization. The CLI cannot resolve a latest deploy because the configured project is no longer visible — it advises re-linking or passing a deploy ID explicitly.","triggerScenarios":"Running a deploy-suggestions/logs command while projectConfig.projectId refers to a project deleted from the organization, belonging to a different organization than the one being queried (organizationId mismatch), or typed/stale in the local Studio config.","commonSituations":"Project was deleted or transferred to another org after linking; developer switched organizations or accounts in the CLI; team members checked out a repo whose Studio config contains someone else's project ID.","solutions":["Re-link your Studio project (`mastra studio link` or equivalent) so the config points to an existing project in your current organization.","Pass the deploy ID explicitly: `mastra studio deploy suggestions <deploy-id>` to bypass project resolution.","Verify the projectId in your local Studio/project config matches a project in the organization you're authenticated against.","Check you're logged into the correct organization/account."],"exampleFix":"// before (stale config)\n{ \"projectId\": \"proj_old_deleted\" }\n// after\nmastra studio link  # re-link to an existing project","handlingStrategy":"validation","validationCode":"const projects = await fetchProjects(token, orgId);\nconst pid = projectConfig?.projectId;\nif (pid && !projects.some(p => p.id === pid)) {\n  console.error(`Linked project ${pid} not in org ${orgId}; re-link with 'mastra studio link'.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const dep = await resolveDeployId(args, ctx);\n} catch (err) {\n  if ((err as Error).message.includes('was not found in this organization')) {\n    console.error('Re-link the project (`mastra studio link`) or pass a deploy ID explicitly.');\n    return;\n  }\n  throw err;\n}","preventionTips":["Re-link the Studio project after deleting or transferring it between organizations.","Don't commit org/project IDs that teammates can't access; document linking in setup steps.","Verify the CLI is authenticated against the same org as the linked project.","Pass deploy IDs explicitly when working across accounts."],"tags":["cli","studio","config","missing-project"],"backgroundTag":"project-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}