{"record":{"id":"eab73efbbc96188f","repo":"affaan-m/ECC","slug":"codex-review-failed-detail-detail","errorCode":null,"errorMessage":"Codex review failed${detail ? `: ${detail}` : ''}","messagePattern":"Codex review failed(.+?)` : ''\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/council-multi-model/scripts/review-with-codex.js","lineNumber":219,"sourceCode":"  try {\n    const result = spawn('codex', buildCodexArgs(tempDir, outputFile), {\n      cwd: tempDir,\n      env: environment,\n      input: prompt,\n      encoding: 'utf8',\n      timeout: options.timeoutMs,\n      maxBuffer: 1024 * 1024,\n      windowsHide: true,\n    });\n\n    if (result.error) {\n      if (result.error.code === 'ETIMEDOUT') throw new Error('Codex review timed out');\n      if (result.error.code === 'ENOENT') throw new Error('Codex CLI is not installed');\n      throw new Error(`Codex invocation failed: ${result.error.message}`);\n    }\n    if (result.status !== 0) {\n      const detail = (result.stderr || '').trim().split('\\n').slice(-1)[0];\n      throw new Error(`Codex review failed${detail ? `: ${detail}` : ''}`);\n    }\n\n    let text;\n    try {\n      text = readFile(outputFile, 'utf8').trim();\n    } catch (error) {\n      throw new Error(`Codex returned no final response: ${error.message}`);\n    }\n    if (!text) throw new Error('Codex returned an empty final response');\n    return `${providerLabel(options.hostProvider)}\\n${text}`;\n  } finally {\n    remove(tempDir, { recursive: true, force: true });\n  }\n}\n\nfunction runStdinReview(options, dependencies = {}) {\n  const stdin = dependencies.stdin || process.stdin;\n  const stdout = dependencies.stdout || process.stdout;","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/skills/council-multi-model/scripts/review-with-codex.js#L201-L237","documentation":"When the codex subprocess spawns successfully but exits with a non-zero status, runReview treats it as a review failure. It takes the last non-empty line of stderr and appends it as detail (': <last stderr line>') to aid diagnosis. This covers policy refusals, sandbox violations, auth errors, and config problems that don't crash the spawn itself.","triggerScenarios":"result.error is null/undefined but result.status !== 0 after the codex exec run. E.g. codex rejects the prompt under --sandbox read-only, --strict-config, or --ignore-rules; auth/credentials invalid; ephemeral constraints violated.","commonSituations":"CODEX_HOME/auth not configured; codex policy rejecting the content; a codex version whose flags differ from the supported 0.146.0; sandbox blocking a needed read; rate limit or quota returning non-zero.","solutions":["Read the appended stderr detail in the error message for the specific failure.","Reproduce manually: run `codex` with the same args (see buildCodexArgs) and the same packet to see full stderr.","Verify Codex auth/CODEX_HOME is set up and that the installed version is exactly 0.146.0.","If a sandbox/policy rule is the cause, confirm the review packet does not require disallowed access."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return runReview(packet, options);\n} catch (error) {\n  if (error.message.startsWith('Codex review failed')) {\n    // error.message already carries the last stderr line; surface it to the caller\n    log.error('codex non-zero exit', { detail: error.message });\n  }\n  throw error;\n}","preventionTips":["Pin Codex to exactly 0.146.0 (SUPPORTED_CODEX_VERSION) so flag/policy behavior matches buildCodexArgs.","Set up CODEX_HOME and auth before invoking, and confirm in a pre-flight probe.","Reproduce failures by running codex manually with the args from buildCodexArgs to read full stderr."],"tags":["subprocess","codex","runtime","exit-code"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}