{"record":{"id":"9b2ed1d6b25eab7f","repo":"t8y2/dbx","slug":"command-failed-join-command-stdout-com","errorCode":null,"errorMessage":"command failed ({' '.join(command)}):\nstdout:\n{completed.stdout}\nstderr:\n{completed.stderr}","messagePattern":"command failed \\((.+?)\\):\nstdout:\n(.+?)\nstderr:\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/bench/run.py","lineNumber":117,"sourceCode":"            with socket.create_connection((host, port), timeout=1):\n                return\n        except OSError:\n            time.sleep(0.5)\n    raise TimeoutError(f\"IoTDB is not reachable at {host}:{port}\")\n\n\ndef run_json(command: list[str], environment: dict[str, str]) -> dict:\n    completed = subprocess.run(\n        command,\n        env=environment,\n        text=True,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.PIPE,\n        check=False,\n        timeout=env_float(\"BENCH_COMMAND_TIMEOUT\", 180.0),\n    )\n    if completed.returncode != 0:\n        raise RuntimeError(\n            f\"command failed ({' '.join(command)}):\\nstdout:\\n{completed.stdout}\\nstderr:\\n{completed.stderr}\"\n        )\n    for line in reversed(completed.stdout.splitlines()):\n        try:\n            value = json.loads(line)\n        except json.JSONDecodeError:\n            continue\n        if isinstance(value, dict):\n            return value\n    raise RuntimeError(f\"command returned no JSON ({' '.join(command)}):\\n{completed.stdout}\")\n\n\ndef measure_rss(command: list[str], environment: dict[str, str]) -> float:\n    process = subprocess.Popen(\n        command,\n        env=environment | {\"IOTDB_BENCH_MODE\": \"hold\"},\n        text=True,\n        stdout=subprocess.PIPE,","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/bench/run.py#L99-L135","documentation":"run_json() executes a benchmark subprocess and requires exit code 0. On any non-zero return code it raises RuntimeError embedding the full command line plus captured stdout and stderr so the underlying failure is visible. check=False is used deliberately so this richer error is raised instead of CalledProcessError.","triggerScenarios":"The spawned benchmark command (called by main) exits non-zero — e.g. the JVM/IoTDB bench tool crashes, bad arguments, missing dependencies, OOM kill, or the command's own internal error — and subprocess.run returns returncode != 0.","commonSituations":"Wrong CLI arguments after a tool upgrade; missing Java/classpath; benchmark script failing on bad config; out-of-memory or SIGKILL; permission denied on the executable.","solutions":["Read the captured stderr/stdout embedded in the RuntimeError message for the root cause","Run the failing command manually with the same env to reproduce interactively","Check the tool's version/arguments match what run_json passes","Increase BENCH_COMMAND_TIMEOUT if the process is being killed by timeout","Verify the executable exists and is runnable (permissions, shebang, runtime present)"],"exampleFix":"// before\nrun_json(cmd, env)  # RuntimeError: command failed (...): exit 1\n// after\n# inspect message stderr, fix tool args, then re-run\nresult = run_json(corrected_cmd, env)","handlingStrategy":"try-catch","validationCode":"import shutil\n\ndef preflight_command(cmd: list[str]) -> None:\n    if shutil.which(cmd[0]) is None:\n        raise SystemExit(f\"command not found: {cmd[0]}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = run_json(command, environment)\nexcept RuntimeError as e:\n    print(f\"benchmark command failed:\\n{e}\")\n    raise SystemExit(1)  # message already contains stdout/stderr for diagnosis","preventionTips":["Always read the stderr section of the raised message before changing code","Validate CLI arguments against the tool's current version (--help) after upgrades","Check the executable's permissions and runtime prerequisites (java, python)","Raise BENCH_COMMAND_TIMEOUT if failures correlate with long runs (SIGKILL/timeout)"],"tags":["subprocess","process-failure","diagnostics","python"],"backgroundTag":"subprocess-exited-nonzero","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}