{"record":{"id":"5d78cfc1564995c8","repo":"mastra-ai/mastra","slug":"no-previous-studio-deploy-found-pass-a-deploy-id","errorCode":null,"errorMessage":"No previous studio deploy found. Pass a deploy ID or deploy first.","messagePattern":"No previous studio deploy found\\. Pass a deploy ID or deploy first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/studio/deploy-suggestions.ts","lineNumber":59,"sourceCode":"}\n\nasync function resolveDeployId(\n  token: string,\n  orgId: string,\n  deployId?: string,\n): Promise<{ deployId: string; projectId?: string }> {\n  if (deployId) {\n    return { deployId };\n  }\n\n  const projectConfig = await loadProjectConfig(process.cwd());\n  const latestDeploy = getLatestProjectDeploy(\n    (await fetchProjects(token, orgId)).filter(project => project.organizationId === orgId),\n    projectConfig?.organizationId === orgId ? projectConfig.projectId : undefined,\n  );\n\n  if (!latestDeploy) {\n    throw new Error('No previous studio deploy found. Pass a deploy ID or deploy first.');\n  }\n\n  p.log.info(\n    `Using latest deploy: ${latestDeploy.deployId}${latestDeploy.projectName ? ` (${latestDeploy.projectName})` : ''}`,\n  );\n  return { deployId: latestDeploy.deployId, projectId: latestDeploy.projectId };\n}\n\nexport async function suggestionsAction(deployId?: string) {\n  p.intro('mastra studio deploy suggestions');\n\n  try {\n    const token = await getToken();\n    const orgId = await getCurrentOrgId();\n    if (!orgId) {\n      p.log.error('No organization selected. Run: mastra auth login');\n      process.exit(1);\n    }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy-suggestions.ts#L41-L77","documentation":"Thrown by resolveDeployId when no deploy could be resolved at all: the project is not linked (so no project lookup was performed) and the fetched projects for the organization yielded no latest deploy. It instructs the user to pass a deploy ID explicitly or deploy first.","triggerScenarios":"Running `mastra studio deploy suggestions` with no deploy ID argument, no linked project in config, and no project in the organization having a latestDeployId — effectively a fresh organization or one where nothing has been deployed yet.","commonSituations":"Fresh account/org with zero deployments; running suggestions before ever running `mastra studio deploy`; authentication scoped to an organization different from where deploys live.","solutions":["Run `mastra studio deploy` first to create a deployment, then retry the command.","Pass an explicit deploy ID: `mastra studio deploy suggestions <deploy-id>`.","Link your Studio project in the config so the resolver can find its deploys.","Confirm your CLI auth targets the organization that actually has deployments."],"exampleFix":"// before\nmastra studio deploy suggestions\n// after\nmastra studio deploy && mastra studio deploy suggestions","handlingStrategy":"validation","validationCode":"const projects = await fetchProjects(token, orgId);\nconst anyDeploy = projects.some(p => p.latestDeployId);\nif (!projectConfig?.projectId && !anyDeploy && !args.deployId) {\n  console.error(`Org ${orgId} has no deploys. Run 'mastra studio deploy' first or pass a deploy ID.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const dep = await resolveDeployId(args, ctx);\n} catch (err) {\n  if ((err as Error).message.includes('No previous studio deploy found')) {\n    console.error('Nothing deployed yet — run `mastra studio deploy` or provide a deploy ID.');\n    return;\n  }\n  throw err;\n}","preventionTips":["Deploy at least once before running deploy-suggestions/logs commands.","Link your project so the resolver can find its deploys automatically.","Pass the deploy ID explicitly in scripts and CI to avoid resolution entirely.","Confirm you're authenticated to the organization containing your deployments."],"tags":["cli","studio","deploy","missing-deploy"],"backgroundTag":"no-deployments-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}