oven-sh/bun · error · Error
Invalid GITHUB_REPOSITORY format: ${repository}
Error message
Invalid GITHUB_REPOSITORY format: ${repository} What it means
GITHUB_REPOSITORY must decompose as 'owner/repo' via split('/'). The variable defaults to 'oven-sh/bun', so this only throws when the env var IS set but malformed — e.g. it contains no slash ('bun') or an empty component ('oven-sh/').
Source
Thrown at scripts/auto-close-duplicates.ts:229
🤖 Generated with [Claude Code](https://claude.ai/code)`,
});
}
async function autoCloseDuplicates(): Promise<void> {
console.log("[DEBUG] Starting auto-close duplicates script");
const token = process.env.GITHUB_TOKEN;
if (!token) {
throw new Error("GITHUB_TOKEN environment variable is required");
}
console.log("[DEBUG] GitHub token found");
// Parse GITHUB_REPOSITORY (format: "owner/repo")
const repository = process.env.GITHUB_REPOSITORY || "oven-sh/bun";
const [owner, repo] = repository.split("/");
if (!owner || !repo) {
throw new Error(`Invalid GITHUB_REPOSITORY format: ${repository}`);
}
console.log(`[DEBUG] Repository: ${owner}/${repo}`);
const threeDaysAgo = new Date();
threeDaysAgo.setDate(threeDaysAgo.getDate() - 3);
console.log(`[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}`);
console.log("[DEBUG] Fetching open issues created more than 3 days ago...");
const allIssues: GitHubIssue[] = [];
let page = 1;
const perPage = 100;
while (true) {
const pageIssues: GitHubIssue[] = await githubRequest(
`/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}`,
token,
);
View on GitHub (pinned to 8c5296ac45)
Solutions
- Set GITHUB_REPOSITORY to the exact 'owner/repo' form (e.g. oven-sh/bun)
- In Actions, pass ${{ github.repository }} rather than typing it manually
- Unset the variable to fall back to the default 'oven-sh/bun'
Example fix
# before GITHUB_REPOSITORY=bun bun scripts/auto-close-duplicates.ts # after GITHUB_REPOSITORY=oven-sh/bun bun scripts/auto-close-duplicates.ts
Defensive patterns
Strategy: validation
Validate before calling
const repository = process.env.GITHUB_REPOSITORY ?? 'oven-sh/bun';
if (!/^[^/\s]+\/[^/\s]+$/.test(repository)) {
throw new Error(`GITHUB_REPOSITORY must be 'owner/repo', got: ${repository}`);
} Prevention
- Pass ${{ github.repository }} instead of hand-typing the value
- Validate the owner/repo shape once at startup with a regex
When it happens
Trigger: A runner or workflow sets GITHUB_REPOSITORY to just the repo name or a URL; manual invocation exporting a wrong value; trailing content after the second component is tolerated but a missing/empty owner or repo is not.
Common situations: Custom self-hosted runner not injecting the standard GITHUB_REPOSITORY; script reused in another repo with a hand-written env value.
Related errors
- GITHUB_TOKEN environment variable is required
- Wrong first byte
- Wrong second byte
- Wrong third byte
- First buffer was modified
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/86815d8068af457d.
Report an issue: GitHub.