{"record":{"id":"845254585c081c08","repo":"mastra-ai/mastra","slug":"failed-to-create-project-res-status","errorCode":null,"errorMessage":"Failed to create project (${res.status})","messagePattern":"Failed to create project \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/init/observability-provision.ts","lineNumber":195,"sourceCode":"async function createProjectByName({\n  token,\n  orgId,\n  name,\n}: {\n  token: string;\n  orgId: string;\n  name: string;\n}): Promise<ObservabilityProject> {\n  // Create as observability-only: no Studio or Server runtime attached. The first\n  // `mastra studio deploy` / `mastra server deploy` flips the matching flag\n  // on the platform side.\n  const res = await platformFetch(`${MASTRA_PLATFORM_API_URL}/v1/studio/projects`, {\n    method: 'POST',\n    headers: { ...authHeaders(token, orgId), 'Content-Type': 'application/json' },\n    body: JSON.stringify({ name, studioEnabled: false, serverEnabled: false }),\n  });\n  if (!res.ok) {\n    throw new Error(`Failed to create project (${res.status})`);\n  }\n  const body = (await res.json()) as { project: ObservabilityProject };\n  return body.project;\n}\n\nasync function mintOrgToken({\n  token,\n  orgId,\n  keyName,\n}: {\n  token: string;\n  orgId: string;\n  keyName: string;\n}): Promise<string> {\n  const res = await platformFetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/tokens`, {\n    method: 'POST',\n    headers: { ...authHeaders(token, orgId), 'Content-Type': 'application/json' },\n    body: JSON.stringify({ name: keyName }),","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/init/observability-provision.ts#L177-L213","documentation":"The CLI attempted to create an observability project via POST /v1/studio/projects and received a non-2xx response. The HTTP status is included in the message.","triggerScenarios":"provisionObservabilityProject or createProject calls createProjectByName and the platform rejects the request: 401/403 (bad token/permissions), 409 or 422 (duplicate/invalid project name), 429 (rate limit), 5xx.","commonSituations":"Creating a project whose name already exists in the org, token lacking org admin rights, expired auth token, or platform-side validation rejecting the name.","solutions":["Check the status: on 409/422 the name likely exists or is invalid — pick a different project name.","On 401/403 re-authenticate (`mastra login`) and confirm you have permission to create projects in the org.","Retry after a delay on 429/5xx (rate limiting or transient outage).","Verify network access to the Mastra platform API (proxy/VPN)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const token = await getValidPlatformToken();\nconst name = projectName.trim();\nif (!name || name.length > 100) throw new Error('Project name must be non-empty and reasonably sized');","typeGuard":null,"tryCatchPattern":"try {\n  await provisionObservabilityProject(...);\n} catch (err) {\n  if (err.message.startsWith('Failed to create project')) {\n    const status = err.message.match(/\\((\\d+)\\)/)?.[1];\n    if (status === '409' || status === '422') {\n      // retry with a different project name\n    } else if (status === '401' || status === '403') {\n      await reauth();\n    }\n  }\n}","preventionTips":["Use a unique project name to avoid conflicts.","Confirm your role allows project creation in the org.","Refresh auth tokens before provisioning."],"tags":["network","api","http","project-creation"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}