mastra-ai/mastra · error · Error

Invalid GitHub repository URL. Use https://github.com/<owner

Error message

Invalid GitHub repository URL. Use https://github.com/<owner>/<repository>.

What it means

Thrown when the template argument looks like a GitHub URL but does not parse as a valid https://github.com/<owner>/<repository> URL. The CLI uses looksLikeGitHubUrl() to detect GitHub-intent input early and fails fast with the expected URL format instead of trying template lookup.

Source

Thrown at packages/cli/src/commands/create/create.ts:750

    throw new Error('No template selected');
  }

  const githubUrl = parseGitHubRepositoryUrl(template);
  if (githubUrl) {
    const spinner = p.spinner();
    spinner.start('Validating GitHub repository...');
    const validation = await validateGitHubProject(githubUrl);
    if (!validation.isValid) {
      spinner.stop('Validation failed');
      p.log.error('This does not appear to be a valid Mastra project:');
      validation.errors.forEach(error => p.log.error(`  - ${error}`));
      throw new Error('Invalid Mastra project');
    }
    spinner.stop('Valid Mastra project ✓');
    return createFromGitHubUrl(githubUrl);
  }
  if (looksLikeGitHubUrl(template)) {
    throw new Error('Invalid GitHub repository URL. Use https://github.com/<owner>/<repository>.');
  }

  const templates = await loadTemplates();
  const found = findTemplateByName(templates, template);
  if (!found) {
    p.log.error(`Template "${template}" not found. Available templates:`);
    templates.forEach(availableTemplate =>
      p.log.info(`  - ${availableTemplate.title} (use: ${availableTemplate.slug.replace('template-', '')})`),
    );
    throw new Error(`Template "${template}" not found`);
  }
  return found;
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Use the full HTTPS web URL format: https://github.com/<owner>/<repository>.
  2. Convert an SSH URL: git@github.com:owner/repo.git → https://github.com/owner/repo.
  3. Strip extra segments like /tree/<branch>, /blob/..., or trailing .git issues by copying the repo root URL from the browser address bar.

Example fix

// before
mastra create git@github.com:mastra-ai/starter.git
// after
mastra create https://github.com/mastra-ai/starter
Defensive patterns

Strategy: validation

Validate before calling

const m = url.match(/^https:\/\/github\.com\/([\w.-]+)\/([\w.-]+?)(\.git)?\/?$/);
if (!m) throw new Error(`Use https://github.com/<owner>/<repository>, got: ${url}`);

Type guard

function isValidGitHubHttpsUrl(v: string): boolean {
  return /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+(\.git)?$/.test(v);
}

Try / catch

try {
  await create(templateArg);
} catch (e) {
  if (/Invalid GitHub repository URL/.test((e as Error).message)) {
    console.error('Convert SSH/tree URLs to the plain https://github.com/<owner>/<repo> form.');
  }
}

Prevention

When it happens

Trigger: `mastra create git@github.com:owner/repo.git`, `https://github.com/owner` (missing repo), `http://...` non-https, or a GitHub URL with extra path segments that the strict pattern rejects.

Common situations: Pasting an SSH clone URL instead of the HTTPS web URL, copying a URL still containing a branch/tree path (e.g. /tree/main), or omitting the repository name.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/0a0683536cb18757. Report an issue: GitHub.