{"record":{"id":"bee4c97a873a06e1","repo":"affaan-m/ECC","slug":"invalid-repo-repo","errorCode":null,"errorMessage":"Invalid repo: ${repo}","messagePattern":"Invalid repo: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/github-discussions.js","lineNumber":13,"sourceCode":"'use strict';\n\nconst { spawnSync } = require('child_process');\n\nconst DEFAULT_DISCUSSION_FIRST = 100;\nconst MAINTAINER_ASSOCIATIONS = new Set(['OWNER', 'MEMBER', 'COLLABORATOR']);\nconst DISCUSSION_ENABLED_QUERY = 'query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } }';\nconst 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 } } } } } }';\n\nfunction splitRepo(repo) {\n  const [owner, name] = String(repo || '').split('/');\n  if (!owner || !name) {\n    throw new Error(`Invalid repo: ${repo}`);\n  }\n  return { owner, name };\n}\n\nfunction runCommand(command, args, options = {}) {\n  const result = spawnSync(command, args, {\n    cwd: options.cwd,\n    env: options.env || process.env,\n    encoding: 'utf8',\n    maxBuffer: 10 * 1024 * 1024,\n  });\n\n  if (result.error) {\n    throw new Error(`${command} ${args.join(' ')} failed: ${result.error.message}`);\n  }\n\n  if (result.status !== 0) {\n    throw new Error(`${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`);","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/github-discussions.js#L1-L31","documentation":"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 || '').","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nawait listDiscussions(process.env.REPO_URL, { first: 10 }); // https://github.com/o/r\n\n// after\nconst m = /github\\.com\\/([^/]+)\\/([^/]+)/.exec(process.env.REPO_URL);\nawait listDiscussions(`${m[1]}/${m[2]}`, { first: 10 });","handlingStrategy":"validation","validationCode":"function assertRepoFormat(repo) {\n  if (!/^[^/]+\\/[^/]+$/.test(String(repo || ''))) {\n    throw new Error(`repo must be 'owner/name', got: ${repo}`);\n  }\n}","typeGuard":"function isRepoSlug(v) {\n  return typeof v === 'string' && /^[^/]+\\/[^/]+$/.test(v);\n}","tryCatchPattern":"try {\n  const d = await listDiscussions(repo, opts);\n} catch (e) {\n  if (/^Invalid repo:/.test(e.message)) {\n    throw new Error(`Fix repo argument (expected owner/name): ${e.message}`);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["github","argument-validation","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}