affaan-m/ECC · error
Invalid repo
Error message
Invalid repo: ${repo} What it means
splitRepo parses a 'owner/name' repository string and throws when the split does not yield both a non-empty owner and name. The github-discussions module uses it to build GraphQL query variables ($owner, $name), so an empty owner or name would produce an invalid query. It also coerces null/undefined repo values to '' via String(repo || '').
Solutions
- Pass the repo in strict 'owner/name' form, e.g. 'affaan-m/ECC'.
- If using env, ensure GITHUB_REPOSITORY is set and non-empty before invoking.
- Strip a full GitHub URL down to its path segments and use the last two as owner/name.
- Validate with a regex like /^[^/]+\/[^/]+$/ before calling the API.
Example fix
// before
await listDiscussions(process.env.REPO_URL, { first: 10 }); // https://github.com/o/r
// after
const m = /github\.com\/([^/]+)\/([^/]+)/.exec(process.env.REPO_URL);
await listDiscussions(`${m[1]}/${m[2]}`, { first: 10 }); Defensive patterns
Strategy: validation
Validate before calling
function assertRepoFormat(repo) {
if (!/^[^/]+\/[^/]+$/.test(String(repo || ''))) {
throw new Error(`repo must be 'owner/name', got: ${repo}`);
}
} Type guard
function isRepoSlug(v) {
return typeof v === 'string' && /^[^/]+\/[^/]+$/.test(v);
} Try / catch
try {
const d = await listDiscussions(repo, opts);
} catch (e) {
if (/^Invalid repo:/.test(e.message)) {
throw new Error(`Fix repo argument (expected owner/name): ${e.message}`);
}
throw e;
} Prevention
- Validate repo strings with an owner/name regex at system boundaries.
- Source repo from GITHUB_REPOSITORY rather than hand-built strings.
- Convert full GitHub URLs to slugs in one shared helper.
When it happens
Trigger: Calling any discussions API entry (e.g. listDiscussions) with repo missing, null, '', 'owner/' (trailing slash, empty name), '/name' (empty owner), or a value containing extra slashes that breaks the two-part split (e.g. 'a/b/c' yields name 'b/c' — actually that one passes; the failing cases are empty components).
Common situations: An unset GITHUB_REPOSITORY environment variable or empty CLI --repo flag; pasting a full URL ('https://github.com/owner/repo') into a field expecting owner/name; typos like a stray trailing slash in config.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- invalid discussion id
- Invalid repo format: " ". Expected "owner/repo".
- invalid repository
- --write requires --json, --markdown, or --format…
- --all-harnesses and --harness are mutually exclusive.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/bee4c97a873a06e1.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/github-discussions.js:13
'use strict';
const { spawnSync } = require('child_process');
const DEFAULT_DISCUSSION_FIRST = 100;
const MAINTAINER_ASSOCIATIONS = new Set(['OWNER', 'MEMBER', 'COLLABORATOR']);
const DISCUSSION_ENABLED_QUERY = 'query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } }';
const DISCUSSION_QUERY = 'query($owner: String!, $name: String!, $first: Int!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled discussions(first: $first, orderBy: {field: UPDATED_AT, direction: DESC}) { totalCount nodes { number title url updatedAt authorAssociation category { name isAnswerable } answer { url authorAssociation } comments(first: 20) { nodes { authorAssociation } } } } } }';
function splitRepo(repo) {
const [owner, name] = String(repo || '').split('/');
if (!owner || !name) {
throw new Error(`Invalid repo: ${repo}`);
}
return { owner, name };
}
function runCommand(command, args, options = {}) {
const result = spawnSync(command, args, {
cwd: options.cwd,
env: options.env || process.env,
encoding: 'utf8',
maxBuffer: 10 * 1024 * 1024,
});
if (result.error) {
throw new Error(`${command} ${args.join(' ')} failed: ${result.error.message}`);
}
if (result.status !== 0) {
throw new Error(`${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`);View on GitHub (pinned to 8321021c54)