{"record":{"id":"2862db27f9d7c545","repo":"affaan-m/ECC","slug":"formatter-exited-with-status-result-status","errorCode":null,"errorMessage":"Formatter exited with status ${result.status}","messagePattern":"Formatter exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/hooks/post-edit-format.js","lineNumber":70,"sourceCode":"        // Biome: `check --write` = format + lint in one pass\n        // Prettier: `--write` = format only\n        const args = formatter === 'biome' ? [...resolved.prefix, 'check', '--write', resolvedFilePath] : [...resolved.prefix, '--write', resolvedFilePath];\n\n        if (process.platform === 'win32' && resolved.bin.endsWith('.cmd')) {\n          // Windows: .cmd files require shell to execute. Guard against\n          // command injection by rejecting paths with shell metacharacters.\n          if (UNSAFE_PATH_CHARS.test(resolvedFilePath)) {\n            throw new Error('File path contains unsafe shell characters');\n          }\n          const result = spawnSync(resolved.bin, args, {\n            cwd: projectRoot,\n            shell: true,\n            stdio: 'pipe',\n            timeout: 15000\n          });\n          if (result.error) throw result.error;\n          if (typeof result.status === 'number' && result.status !== 0) {\n            throw new Error(result.stderr?.toString() || `Formatter exited with status ${result.status}`);\n          }\n        } else {\n          execFileSync(resolved.bin, args, {\n            cwd: projectRoot,\n            stdio: ['pipe', 'pipe', 'pipe'],\n            timeout: 15000\n          });\n        }\n      } catch {\n        // Formatter not installed, file missing, or failed — non-blocking\n      }\n    }\n  } catch {\n    // Invalid input — pass through\n  }\n\n  return rawInput;\n}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/hooks/post-edit-format.js#L52-L88","documentation":"When the Windows .cmd formatter is spawned and exits with a non-zero status but writes nothing to stderr, the hook throws a status-only message. Like the other formatter errors it is caught and swallowed, so the edit is not blocked; the file is simply left unformatted.","triggerScenarios":"Biome or Prettier exits non-zero on the edited file (syntax error, unsupported syntax, config error) while emitting no stderr output; or the formatter binary is partially broken on Windows.","commonSituations":"Editing a file with a syntax error the formatter cannot parse, a formatter version that chokes on a new syntax feature, or a corrupt formatter install that exits non-zero silently.","solutions":["Run the formatter manually on the file to see the real diagnostic","Fix any syntax errors in the edited file","Reinstall or upgrade the formatter (biome/prettier) in the project"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const { spawnSync } = require('child_process');\nfunction formatterOkay(bin, projectRoot) {\n  const r = spawnSync(bin, ['--version'], { cwd: projectRoot });\n  return !r.error && r.status === 0;\n}","typeGuard":"function isFormatterStatusZero(result) {\n  return result && !result.error && (typeof result.status !== 'number' || result.status === 0);\n}","tryCatchPattern":"try { runFormatter(bin, args); }\ncatch (err) {\n  if (/Formatter exited with status/.test(err.message)) {\n    console.warn('Formatter failed; run it manually to see diagnostics:', err.message);\n    return; // non-blocking\n  }\n  throw err;\n}","preventionTips":["Run the formatter manually on a failing file to surface the real diagnostic","Keep formatter versions current so new syntax is supported","Do not rely on the hook for syntax validation; fix parse errors first"],"tags":["formatting","windows","hooks","biome","prettier"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}