yamadashy/repomix · error · RepomixError

Invalid owner/repo in repo URL

Error message

Invalid owner/repo in repo URL

What it means

When a remote value is parsed, Repomix extracts the owner/repo shorthand from the parsed URL's full_name and validates it. If the trailing owner/repo segment contains characters that are not a valid shorthand (bad characters, empty segments, malformed names), this error is thrown.

Source

Thrown at src/core/git/gitRemoteParse.ts:97

  // - Legacy: https://org.visualstudio.com/project/_git/repo
  if (isAzureDevOpsUrl(remoteValue)) {
    return {
      repoUrl: remoteValue,
      remoteBranch: undefined,
    };
  }

  try {
    const parsedFields = gitUrlParse(remoteValue, refs) as IGitUrl;

    // This will make parsedFields.toString() automatically append '.git' to the returned url
    parsedFields.git_suffix = true;

    const ownerSlashRepo =
      parsedFields.full_name.split('/').length > 1 ? parsedFields.full_name.split('/').slice(-2).join('/') : '';

    if (ownerSlashRepo !== '' && !isValidShorthand(ownerSlashRepo)) {
      throw new RepomixError('Invalid owner/repo in repo URL');
    }

    const repoUrl = parsedFields.toString(parsedFields.protocol);

    if (parsedFields.ref) {
      return {
        repoUrl: repoUrl,
        remoteBranch: parsedFields.ref,
      };
    }

    if (parsedFields.commit) {
      return {
        repoUrl: repoUrl,
        remoteBranch: parsedFields.commit,
      };
    }

View on GitHub (pinned to f465ad9093)

Solutions

  1. Print the URL and confirm it ends with a valid owner/repo (e.g. github.com/owner/repo).
  2. Remove stray slashes, dots, or encoded characters from the URL.
  3. If only a shorthand is intended, pass just 'owner/repo' instead of a full URL.
  4. URL-encode/fix characters that are not valid in GitHub/GitLab names.

Example fix

// before
parseRemoteValue('https://github.com//repo-')
// after
parseRemoteValue('https://github.com/owner/repo')
Defensive patterns

Strategy: validation

Validate before calling

const isValidShorthand = (s: string) => /^[\w.-]+\/[\w.-]+$/.test(s);
const tail = remoteValue.replace(/\.git$/, '').split('/').slice(-2).join('/');
if (!isValidShorthand(tail)) throw new Error(`Bad owner/repo tail: ${tail}`);

Type guard

const hasValidOwnerRepo = (url: string): boolean => {
  const parts = url.replace(/\.git$/, '').split('/').filter(Boolean);
  return parts.length >= 2 && /^[\w.-]+$/.test(parts.at(-2)!) && /^[\w.-]+$/.test(parts.at(-1)!);
};

Try / catch

try {
  await runRepomix({ remote: remoteValue });
} catch (e) {
  if (e instanceof RepomixError && e.message === 'Invalid owner/repo in repo URL') {
    console.error('Fix the owner/repo segment of the URL.');
  }
}

Prevention

When it happens

Trigger: parseRemoteValueInternal (via parseRemoteValue/parsed) receives a URL whose full_name's last two segments fail isValidShorthand — e.g. 'https://github.com//', URLs with encoded or illegal characters in owner/repo, or deeply nested paths with invalid tail segments.

Common situations: Hand-edited URLs with double slashes; URLs pasted from a web UI including extra path segments or query/fragment remnants; templated URLs where owner or repo interpolated as empty.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/4bf106053d53ea08. Report an issue: GitHub.