{"record":{"id":"9f203770f764bca1","repo":"affaan-m/ECC","slug":"command-args-join-failed-result-erro","errorCode":null,"errorMessage":"${command} ${args.join(' ')} failed: ${result.error.message}","messagePattern":"(.+?) (.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"scripts/lib/github-coordination/gh-api.js","lineNumber":45,"sourceCode":"    return String(label.name || label.label || '').trim();\n  }\n  return '';\n}\n\nfunction normalizeLabels(labels) {\n  return Array.from(new Set((Array.isArray(labels) ? labels : []).map(normalizeLabelValue).filter(Boolean))).sort();\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()}`);\n  }\n\n  return result.stdout || '';\n}\n\n// ECC_GH_SHIM creates a trust boundary: when set, shimPath replaces the real\n// `gh` binary and command/commandArgs execute an arbitrary script via\n// process.execPath. This variable MUST only be set in trusted, isolated test\n// environments (e.g., a test's own temp directory). Never set ECC_GH_SHIM in\n// production — doing so allows arbitrary script execution under the caller's\n// privileges.\nfunction runGh(args, options = {}) {\n  const shimPath = process.env.ECC_GH_SHIM;\n  const command = shimPath ? process.execPath : 'gh';","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/github-coordination/gh-api.js#L27-L63","documentation":"Thrown by runCommand when spawnSync returns a non-null result.error, meaning the child process could not be spawned at all. This is distinct from a non-zero exit (which is error 136): here the binary was not found, was not executable, or the spawn itself failed (ENOENT, EACCES, E2BIG). The wrapped error.message identifies the OS-level cause.","triggerScenarios":"gh is not installed or not on PATH (ENOENT); the binary path lacks execute permission (EACCES); ECC_GH_SHIM points at a non-existent path; the args/env are too large (E2BIG).","commonSituations":"Fresh CI runner without gh installed; local dev machine missing gh; PATH not propagated to the Node process; shim path configured wrong in tests.","solutions":["Install the GitHub CLI (gh) and ensure it is on PATH: run `gh --version` in the same shell/env as the Node process.","Verify process.env.PATH inside the Node process includes the directory containing gh.","If using ECC_GH_SHIM for tests, confirm the shim path exists and is executable.","Check result.error.code (ENOENT vs EACCES) to distinguish missing-binary from permission issues."],"exampleFix":"// before\nrunGh(['issue', 'view', String(n)]);\n\n// after — verify gh availability with a clear message\nconst { spawnSync } = require('child_process');\nconst probe = spawnSync('gh', ['--version'], { encoding: 'utf8' });\nif (probe.error) {\n  throw new Error(`GitHub CLI (gh) not available: ${probe.error.message}. Install from https://cli.github.com`);\n}\nrunGh(['issue', 'view', String(n)]);","handlingStrategy":"validation","validationCode":"const probe = spawnSync('gh', ['--version'], { encoding: 'utf8' });\nif (probe.error) {\n  throw new Error(`gh not available: ${probe.error.message}. Install from https://cli.github.com`);\n}","typeGuard":"function ghAvailable() {\n  const { error } = spawnSync('gh', ['--version'], { encoding: 'utf8' });\n  return !error;\n}","tryCatchPattern":"try {\n  runGh(args);\n} catch (e) {\n  if (/failed: ENOENT/.test(e.message)) { throw new Error('Install the GitHub CLI (gh) and ensure it is on PATH'); }\n  throw e;\n}","preventionTips":["Install gh and confirm `gh --version` works in the same env as Node.","Ensure process.env.PATH is propagated to child processes.","In tests, set ECC_GH_SHIM to a real, executable shim path."],"tags":["github-coordination","gh-api","spawn","environment","enoent"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}