{"record":{"id":"3f9e782a9e91d2be","repo":"affaan-m/ECC","slug":"classifier-subprocess-failed-rc-result-returncod","errorCode":null,"errorMessage":"classifier subprocess failed (rc={result.returncode}): {result.stderr[:500]}","messagePattern":"classifier subprocess failed \\(rc=(.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/skill-comply/scripts/classifier.py","lineNumber":54,"sourceCode":"        for i, event in enumerate(trace)\n    )\n\n    prompt_template = (PROMPTS_DIR / \"classifier.md\").read_text()\n    prompt = (\n        prompt_template\n        .replace(\"{steps_description}\", steps_desc)\n        .replace(\"{tool_calls}\", tool_calls)\n    )\n\n    result = subprocess.run(\n        [\"claude\", \"-p\", prompt, \"--model\", model, \"--output-format\", \"text\"],\n        capture_output=True,\n        text=True,\n        timeout=60,\n    )\n\n    if result.returncode != 0:\n        raise RuntimeError(\n            f\"classifier subprocess failed (rc={result.returncode}): \"\n            f\"{result.stderr[:500]}\"\n        )\n\n    return _parse_classification(result.stdout)\n\n\ndef _parse_classification(text: str) -> dict[str, list[int]]:\n    \"\"\"Parse LLM classification output into {step_id: [event_indices]}.\"\"\"\n    text = text.strip()\n    # Strip markdown fences\n    lines = text.splitlines()\n    if lines and lines[0].startswith(\"```\"):\n        lines = lines[1:]\n    if lines and lines[-1].startswith(\"```\"):\n        lines = lines[:-1]\n    cleaned = \"\\n\".join(lines)\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/skill-comply/scripts/classifier.py#L36-L72","documentation":"classify_events in skill-comply's classifier.py shells out to a classifier subprocess and raises this RuntimeError when the subprocess exits with a nonzero return code. The first 500 characters of the subprocess's stderr are embedded in the message to surface the underlying tool's diagnostic output.","triggerScenarios":"The external classifier binary is missing from PATH (rc=127) or not executable (rc=126); the classifier crashes on the input (segfault, unhandled exception, rc=1/2); it exits nonzero due to its own bad configuration, bad model file, or input encoding problems.","commonSituations":"Fresh machine/container without the classifier installed; wrong CLASSIFIER path or version after an upgrade; classifier model/data files missing or corrupted; input containing characters or sizes the classifier cannot handle.","solutions":["Read the rc and embedded stderr in the message to identify the classifier's own failure, and fix that root cause first.","Verify the classifier binary is installed and on PATH (which <classifier>; run it manually on a small sample).","Check classifier configuration, model files, and version compatibility with the input schema.","Confirm the input passed to the subprocess is well-formed and encodable (UTF-8, expected event shape).","Wrap the call in try/except RuntimeError to convert it into a grading failure with the stderr surfaced to logs."],"exampleFix":"// before: crash propagates raw\nresult = subprocess.run([...], capture_output=True, text=True, timeout=60)\nif result.returncode != 0:\n    raise RuntimeError(f\"classifier subprocess failed (rc={result.returncode}): {result.stderr[:500]}\")\n\n// after: handle gracefully at the call site\ntry:\n    classification = classify_events(events)\nexcept RuntimeError as e:\n    logger.error(\"classifier unavailable: %s\", e)\n    return grade_result(events, skipped=True)","handlingStrategy":"try-catch","validationCode":"import shutil\nbinary = cmd[0]\nif shutil.which(binary) is None:\n    raise RuntimeError(f\"classifier binary '{binary}' not found on PATH\")","typeGuard":null,"tryCatchPattern":"try:\n    classification = classify_events(events)\nexcept RuntimeError as e:\n    log.error(\"classifier subprocess failed: %s\", e)\n    # degrade: skip grading or fall back to manual review\nexcept subprocess.TimeoutExpired:\n    log.error(\"classifier timed out after 60s\")","preventionTips":["Verify the classifier is installed and on PATH in your environment/CI image","Run the classifier manually on a small sample after version upgrades","Log full stderr (not just 500 chars) when debugging","Pin the classifier version and validate model/config files at deploy time"],"tags":["subprocess","external-tool","nonzero-exit","dependency"],"backgroundTag":"command-not-found","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"}