pbakaus/impeccable · error · Error

Missing repository. Pass --repo owner/name or set GITHUB_REP

Error message

Missing repository. Pass --repo owner/name or set GITHUB_REPOSITORY.

What it means

Thrown by sheriff.mjs main when neither --repo nor the GITHUB_REPOSITORY env var provides an owner/name repository string (or the value lacks a slash). Sheriff needs a concrete repo to query PRs via gh, so an absent/malformed repo is a hard stop before any GitHub call.

Source

Thrown at scripts/github/sheriff.mjs:395

    '',
    `If nothing changes, this PR may be closed on or after ${closeDate}. Happy to reopen when it is ready to continue.`,
  ].join('\n');
}

export function staleCloseComment(pr, { waitingDays }) {
  return [
    CLOSE_MARKER,
    `Closing this because it has been waiting on contributor action for ${waitingDays} days.`,
    '',
    'Please open a fresh PR, or ask for this one to be reopened, after the outstanding feedback is addressed.',
  ].join('\n');
}

export async function main(argv = process.argv.slice(2)) {
  const options = parseArgs(argv);
  const repo = options.repo || process.env.GITHUB_REPOSITORY;
  if (!repo || !repo.includes('/')) {
    throw new Error('Missing repository. Pass --repo owner/name or set GITHUB_REPOSITORY.');
  }

  if (options.apply && options.ensureLabels) {
    ensureLabels(repo, options);
  }

  const prs = fetchOpenPullRequests(repo).map(normalizePullRequest);
  hydrateIssueComments(repo, prs);
  hydrateMissingWaitingLabelEvents(repo, prs);
  const plans = prs.map((pr) => evaluatePullRequest(pr, options));

  for (const plan of plans) {
    printPlan(plan, { apply: options.apply });
    if (options.apply) applyPlan(repo, plan, options);
  }

  console.log(`${options.apply ? 'Applied' : 'Dry run'} sheriff pass for ${plans.length} open PR(s).`);
}

View on GitHub (pinned to d14711ae3d)

Solutions

  1. Pass the repo explicitly: `sheriff.mjs --repo owner/name`.
  2. Export GITHUB_REPOSITORY=owner/name before running.
  3. In GitHub Actions, ensure the job has access to the default GITHUB_REPOSITORY env var.

Example fix

# before
node scripts/github/sheriff.mjs --apply

# after
node scripts/github/sheriff.mjs --repo owner/name --apply
Defensive patterns

Strategy: validation

Validate before calling

function resolveRepoSlug(options, env) {
  const repo = options.repo || env.GITHUB_REPOSITORY;
  return typeof repo === 'string' && repo.includes('/') ? repo : null;
}

Type guard

function isRepoSlug(value) {
  return typeof value === 'string' && /^[\w.-]+\/[\w.-]+$/.test(value);
}

Try / catch

const repo = resolveRepoSlug(options, process.env);
if (!repo) {
  console.error('Missing repository. Pass --repo owner/name or set GITHUB_REPOSITORY.');
  process.exit(2);
}

Prevention

When it happens

Trigger: Running sheriff without --repo and without GITHUB_REPOSITORY set, or with a value like 'myrepo' that has no '/' separator.

Common situations: Local invocation outside GitHub Actions (where GITHUB_REPOSITORY is auto-set), a typo in the repo slug, or a workflow missing the env var.

Related errors


AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13). Data as JSON: /api/errors/86ed9685247af4e3. Report an issue: GitHub.