{"record":{"id":"51b3b37440dc661f","repo":"mastra-ai/mastra","slug":"platform-resolution-failed","errorCode":"PLATFORM_RESOLUTION_FAILED","errorMessage":"Could not resolve platform deployment URL","messagePattern":"Could not resolve platform deployment URL","errorType":"error_code","errorClass":"ApiCliError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/api/target.ts","lineNumber":87,"sourceCode":"  if (await canReachLocal(timeoutMs, fetchFn, apiPrefix)) {\n    return { baseUrl: LOCAL_URL, headers: customHeaders, timeoutMs, apiPrefix };\n  }\n\n  const config = await loadProjectConfig(process.cwd());\n  if (!config) {\n    throw new ApiCliError('SERVER_UNREACHABLE', 'Could not connect to target server');\n  }\n\n  try {\n    const token = await getToken();\n    const projects = await fetchServerProjects(token, config.organizationId);\n    const project = projects.find(\n      candidate => candidate.id === config.projectId || candidate.slug === config.projectSlug,\n    );\n    const baseUrl = project?.instanceUrl;\n\n    if (!baseUrl) {\n      throw new ApiCliError('PLATFORM_RESOLUTION_FAILED', 'Could not resolve platform deployment URL', {\n        projectId: config.projectId,\n        projectSlug: config.projectSlug,\n      });\n    }\n\n    return {\n      baseUrl,\n      headers: { Authorization: `Bearer ${token}`, ...customHeaders },\n      timeoutMs,\n      apiPrefix,\n    };\n  } catch (error) {\n    if (error instanceof ApiCliError) throw error;\n    throw new ApiCliError('PLATFORM_RESOLUTION_FAILED', 'Could not resolve platform deployment URL', {\n      message: error instanceof Error ? error.message : String(error),\n    });\n  }\n}","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/api/target.ts#L69-L105","documentation":"When falling back to the Mastra platform, resolveTarget loads the project config, authenticates, and looks up the project among fetchServerProjects results by projectId or projectSlug. If the matching project has no instanceUrl (or no project matched so project is undefined), it throws PLATFORM_RESOLUTION_FAILED with the projectId/projectSlug as details.","triggerScenarios":"config.projectId/projectSlug reference a project that no longer exists, was renamed, or whose deployment hasn't been provisioned yet, so `project?.instanceUrl` is undefined.","commonSituations":"Deleting or renaming the project in the Mastra platform while the local config still points at the old id/slug; deployment still building (no instance URL yet); token scoped to an organization that doesn't contain the project; stale config copied from another repo.","solutions":["Verify the projectId/projectSlug in your project config against the platform dashboard and update it to the current project","Ensure the deployment exists and is running so instanceUrl is assigned, then retry","Re-authenticate (getToken) if the token lacks access to the organization that owns the project","Regenerate the project config (re-init) if it was copied from another project and references stale identifiers"],"exampleFix":"// before (project config points at deleted project)\n{ \"projectId\": \"prj_abc\" }\n// after\n{ \"projectId\": \"prj_xyz\", \"projectSlug\": \"my-agent-app\" }","handlingStrategy":"validation","validationCode":"const projects = await fetchServerProjects(token);\nconst match = projects.find(p => p.id === cfg.projectId || p.slug === cfg.projectSlug);\nif (!match?.instanceUrl) throw new Error(`Project ${cfg.projectId ?? cfg.projectSlug} has no running deployment`);","typeGuard":"function hasInstanceUrl(p: { instanceUrl?: string } | undefined): p is { instanceUrl: string } { return typeof p?.instanceUrl === 'string' && p.instanceUrl.length > 0; }","tryCatchPattern":"try { await runApiCommand(cmd, args); } catch (e) { if (String(e).includes('PLATFORM_RESOLUTION_FAILED')) { console.error('Check projectId/projectSlug in project config and that the deployment is live'); } else throw e; }","preventionTips":["Sync project config with the platform after renaming or recreating projects","Wait for deployments to finish provisioning before CLI use","Ensure the auth token belongs to the org that owns the projectId","Use explicit --target to avoid platform lookup entirely"],"tags":["platform","configuration","deployment"],"backgroundTag":"platform-project-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}