abhigyanpatwari/GitNexus · error · Error

must not end with "/" or "."

Error message

must not end with "/" or "."

What it means

validateAutoSyncBranchName rejects branch names ending with "/" or ".", mirroring git's own check-ref-format rules: a ref may not end with a slash or dot. The auto-sync config parser enforces this before handing the branch name to git, so malformed names fail at config-parse time with a clear message.

Source

Thrown at gitnexus/src/core/auto-sync/config.ts:343

    repoName.startsWith('-') ||
    !REMOTE_REPO_NAME_PATTERN.test(repoName)
  ) {
    throw new Error(
      'repository name must use only letters, digits, ".", "_", or "-" and must not be "unknown"',
    );
  }
}

export function validateAutoSyncBranchName(branch: string): void {
  if (!branch.trim()) throw new Error('must not be empty');
  if (/[\s\0-\x1f\x7f]/.test(branch))
    throw new Error('must not contain whitespace or control characters');
  if (/[~^:?*[\\]/.test(branch)) throw new Error('contains characters not allowed in a git ref');
  if (branch.startsWith('-')) throw new Error('must not start with "-"');
  if (branch.startsWith('/')) throw new Error('must not start with "/"');
  if (branch.includes('..')) throw new Error('must not contain ".."');
  if (branch.includes('`')) throw new Error('must not contain backticks');
  if (branch.endsWith('/') || branch.endsWith('.')) throw new Error('must not end with "/" or "."');
  if (branch.includes('//')) throw new Error('must not contain consecutive slashes');
  if (branch.includes('@{')) throw new Error('must not contain "@{"');
  if (
    branch
      .split('/')
      .some(
        (component) =>
          component.startsWith('.') || component.endsWith('.') || component.endsWith('.lock'),
      )
  )
    throw new Error('must not contain hidden, trailing-dot, or .lock path components');
}

export function parseDurationMs(value: unknown): number {
  if (typeof value === 'number') return value * 1_000;
  const raw = String(value ?? '').trim();
  const match = /^(\d+)(ms|s|m)?$/.exec(raw);
  if (!match) return Number.NaN;

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Strip the trailing "/" or "." from the branch name in the auto-sync config.
  2. If the name is built programmatically, trim trailing separators/dots before assigning it.
  3. Validate with git check-ref-format or re-run parseAutoSyncConfig to confirm.

Example fix

// before
branch: "feature/auto-sync/"
// after
branch: "feature/auto-sync"
Defensive patterns

Strategy: validation

Validate before calling

if (/[/$.]$/.test(branch)) throw new Error('branch name must not end with "/" or "."');

Prevention

When it happens

Trigger: parseAutoSyncConfig receives a branch value whose last character is "/" or ".", e.g. "feature/" or "release.v1."

Common situations: Trailing slashes/dots introduced by string concatenation in generated configs, hand-edited YAML with typos, or copying a path-like value ("refs/heads/main/") instead of the branch name.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08). Data as JSON: /api/errors/d04e438eeda96324. Report an issue: GitHub.