{"record":{"id":"a84a8bf7d624887a","repo":"apache/kafka","slug":"failure-in-executing-following-command","errorCode":null,"errorMessage":"Failure in executing following command:- ","messagePattern":"Failure in executing following command:- ","errorType":"exception","errorClass":"SystemError","httpStatus":null,"severity":"error","filePath":"docker/common.py","lineNumber":25,"sourceCode":"# (the \"License\"); you may not use this file except in compliance with\n# the License.  You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport subprocess\nimport tempfile\nimport os\nimport shutil\n\ndef execute(command):\n    if subprocess.run(command).returncode != 0:\n        raise SystemError(\"Failure in executing following command:- \", \" \".join(command))\n\ndef get_input(message):\n    value = input(message)\n    if value == \"\":\n        raise ValueError(\"This field cannot be empty\")\n    return value\n\ndef build_docker_image_runner(command, image_type, kafka_archive=None):\n    temp_dir_path = tempfile.mkdtemp()\n    current_dir = os.path.dirname(os.path.realpath(__file__))\n    shutil.copytree(f\"{current_dir}/{image_type}\", f\"{temp_dir_path}/{image_type}\", dirs_exist_ok=True)\n    shutil.copytree(f\"{current_dir}/resources\", f\"{temp_dir_path}/{image_type}/resources\", dirs_exist_ok=True)\n    shutil.copy(f\"{current_dir}/server.properties\", f\"{temp_dir_path}/{image_type}\")\n    if kafka_archive:\n        shutil.copy(kafka_archive, f\"{temp_dir_path}/{image_type}/kafka.tgz\")\n    command = command.replace(\"$DOCKER_FILE\", f\"{temp_dir_path}/{image_type}/Dockerfile\")\n    command = command.replace(\"$DOCKER_DIR\", f\"{temp_dir_path}/{image_type}\")\n    try:","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/docker/common.py#L7-L43","documentation":"docker/common.py:execute runs a command via subprocess.run and, if the return code is non-zero, raises SystemError with the joined command string. (Note: SystemError is a Python builtin reserved for interpreter-level errors - using it here is questionable, but it is the shipped behavior.) The actual stderr/stdout of the failing command is NOT captured into the exception; only the command line is included.","triggerScenarios":"Calling execute([...]) where the subprocess exits non-zero - e.g. `docker buildx create`, `docker buildx rm`, `git`, or any CLI invoked by the docker/release scripts that fails.","commonSituations":"Docker not installed or not on PATH; permission denied talking to the docker daemon; buildx plugin missing; a previous run left state that makes the command fail (e.g. builder already exists).","solutions":["Re-run the exact failing command manually to see its stderr (execute hides it).","Ensure docker and docker buildx are installed and the daemon is reachable (`docker info`).","If the failure is 'builder already exists', remove it first (`docker buildx rm kafka-builder`).","Patch execute locally to capture stderr (subprocess.run(..., check=True, capture_output=True)) so the error surface is visible."],"exampleFix":"# before (library code swallows stderr)\nexecute([\"docker\", \"buildx\", \"create\", \"--name\", \"kafka-builder\", \"--use\"])\n# raises SystemError('Failure in executing following command:- ', 'docker buildx create ...')\n\n# debug locally\n$ docker buildx create --name kafka-builder --use\n# stderr shows the real cause, e.g. 'existing instance ...'","handlingStrategy":"try-catch","validationCode":"import shutil\nif shutil.which(command[0]) is None:\n    raise SystemExit(f\"'{command[0]}' not found on PATH\")","typeGuard":"null","tryCatchPattern":"from common import execute\ntry:\n    execute(cmd)\nexcept SystemError as e:\n    print(f\"Command failed: {' '.join(cmd)}\\nRe-run manually for stderr.\", file=sys.stderr)\n    raise","preventionTips":["Re-run the failing command manually to see its stderr (execute swallows it).","Verify docker / docker buildx are installed and the daemon is reachable before running the release scripts."],"tags":["docker","subprocess","release-tools","python","tooling"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}