{"record":{"id":"95f73106627dfa01","repo":"mastra-ai/mastra","slug":"invalid-mastra-project","errorCode":null,"errorMessage":"Invalid Mastra project","messagePattern":"Invalid Mastra project","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/create/create.ts","lineNumber":744,"sourceCode":"    const selected = await runCreatePrompt(signal => selectTemplate(templates, { signal }));\n    if (!selected) cancelCreate();\n    return selected;\n  }\n\n  if (typeof template !== 'string') {\n    throw new Error('No template selected');\n  }\n\n  const githubUrl = parseGitHubRepositoryUrl(template);\n  if (githubUrl) {\n    const spinner = p.spinner();\n    spinner.start('Validating GitHub repository...');\n    const validation = await validateGitHubProject(githubUrl);\n    if (!validation.isValid) {\n      spinner.stop('Validation failed');\n      p.log.error('This does not appear to be a valid Mastra project:');\n      validation.errors.forEach(error => p.log.error(`  - ${error}`));\n      throw new Error('Invalid Mastra project');\n    }\n    spinner.stop('Valid Mastra project ✓');\n    return createFromGitHubUrl(githubUrl);\n  }\n  if (looksLikeGitHubUrl(template)) {\n    throw new Error('Invalid GitHub repository URL. Use https://github.com/<owner>/<repository>.');\n  }\n\n  const templates = await loadTemplates();\n  const found = findTemplateByName(templates, template);\n  if (!found) {\n    p.log.error(`Template \"${template}\" not found. Available templates:`);\n    templates.forEach(availableTemplate =>\n      p.log.info(`  - ${availableTemplate.title} (use: ${availableTemplate.slug.replace('template-', '')})`),\n    );\n    throw new Error(`Template \"${template}\" not found`);\n  }\n  return found;","sourceCodeStart":726,"sourceCodeEnd":762,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/create/create.ts#L726-L762","documentation":"Thrown by `mastra create --github <url>` after validateGitHubProject() reports the remote repository is not a recognizable Mastra project. The CLI first clones/inspects the GitHub repo and runs structural validation; if validation.isValid is false it prints each validation error and aborts. This prevents scaffolding from a repo that lacks the required Mastra project structure.","triggerScenarios":"Running `mastra create` with a GitHub URL whose repository fails validateGitHubProject() — e.g. missing package.json with mastra dependencies, no mastra config, or wrong directory layout.","commonSituations":"Pointing the CLI at a fork, a fork with renamed packages, a plain JS repo with an unrelated Mastra-like setup, a repo on a non-default branch layout, or a URL typo landing on the wrong repository.","solutions":["Read the '- <error>' lines printed above the throw — validateGitHubProject lists exactly which structural checks failed.","Verify the URL points at the intended Mastra starter/template repository (owner and repo name).","Open the repo and confirm package.json contains mastra dependencies (e.g. @mastra/core) and the expected mastra project files.","If the repo is yours, restructure it to match the Mastra starter layout or start from an official template instead."],"exampleFix":"// before\nmastra create --github https://github.com/me/my-random-repo\n// after\nmastra create --github https://github.com/mastra-ai/starter-template","handlingStrategy":"validation","validationCode":"const m = url.match(/^https:\\/\\/github\\.com\\/([\\w.-]+)\\/([\\w.-]+?)(\\.git)?\\/?$/);\nif (!m) throw new Error('Not a GitHub repo URL');\n// then confirm the repo is a Mastra project (has mastra deps/config) before passing to `mastra create`","typeGuard":"function isGitHubRepoUrl(v: string): boolean {\n  return /^https:\\/\\/github\\.com\\/[\\w.-]+\\/[\\w.-]+(\\.git)?$/.test(v);\n}","tryCatchPattern":"try {\n  await createFromGitHubUrl(url);\n} catch (e) {\n  if ((e as Error).message === 'Invalid Mastra project') {\n    console.error('Repo is not a Mastra project — use an official Mastra starter or fix the repo layout.');\n  }\n}","preventionTips":["Only pass URLs of known Mastra starter/template repositories.","Copy the repo root URL from the browser, not a deep link.","Check the repo has @mastra/core in package.json before scaffolding from it."],"tags":["cli","validation","github","scaffold"],"backgroundTag":"invalid-project-structure","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}