apache/kafka · error · SystemError
Failure in executing following command:-
Error message
Failure in executing following command:-
What it means
Raised by docker/common.execute() when subprocess.run(command) returns a non-zero exit code. execute() is the shared wrapper used by build_docker_image_runner, docker_release, and related scripts to run shell commands (docker build, docker buildx create/rm, etc.). The message echoes the joined command so the failing invocation is identifiable, though the original stderr is lost.
Source
Thrown at docker/common.py:25
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import subprocess
import tempfile
import os
import shutil
def execute(command):
if subprocess.run(command).returncode != 0:
raise SystemError("Failure in executing following command:- ", " ".join(command))
def get_input(message):
value = input(message)
if value == "":
raise ValueError("This field cannot be empty")
return value
def build_docker_image_runner(command, image_type, kafka_archive=None):
temp_dir_path = tempfile.mkdtemp()
current_dir = os.path.dirname(os.path.realpath(__file__))
shutil.copytree(f"{current_dir}/{image_type}", f"{temp_dir_path}/{image_type}", dirs_exist_ok=True)
shutil.copytree(f"{current_dir}/resources", f"{temp_dir_path}/{image_type}/resources", dirs_exist_ok=True)
shutil.copy(f"{current_dir}/server.properties", f"{temp_dir_path}/{image_type}")
if kafka_archive:
shutil.copy(kafka_archive, f"{temp_dir_path}/{image_type}/kafka.tgz")
command = command.replace("$DOCKER_FILE", f"{temp_dir_path}/{image_type}/Dockerfile")
command = command.replace("$DOCKER_DIR", f"{temp_dir_path}/{image_type}")
try:View on GitHub (pinned to c31c9215e1)
Solutions
- Re-run the exact command shown in the error message manually to see docker's stderr, which execute() discards.
- Ensure docker is installed, running, and docker buildx is available: docker buildx version.
- If the failure is 'kafka-builder already exists', run docker buildx rm kafka-builder first; if 'not found', ignore or guard remove_builder().
- Verify prerequisites from docker_release.py docstring: logged in to registry, buildx enabled, adequate disk.
Example fix
# before (execute swallows stderr)
subprocess.run(command).returncode != 0 # you see only the command
# after (capture and surface stderr)
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
raise SystemError(f"Failure executing {command}: {result.stderr}") Defensive patterns
Strategy: try-catch
Validate before calling
# Validate the command is well-formed and the binary is on PATH before running.
import shutil, shlex
binary = command.split()[0] if isinstance(command, str) else command[0]
if not shutil.which(binary):
raise FileNotFoundError(f"Executable not found on PATH: {binary}") Type guard
# Accept only a non-empty, shell-safe command list.
def is_executable_command(cmd) -> bool:
if not cmd:
return False
parts = cmd if isinstance(cmd, list) else shlex.split(cmd)
return len(parts) > 0 and bool(shutil.which(parts[0])) Try / catch
from common import execute
try:
execute(command)
except SystemError as e:
# Inspect the captured command; retry only transient failures, not bad input.
failed_cmd = e.args[1] if len(e.args) > 1 else "<unknown>"
raise RuntimeError(f"Command failed, inspect manually: {failed_cmd}") from e Prevention
- Always run docker/gradle/git commands through execute() and surface SystemExit rather than ignoring return codes.
- Validate the command string (non-empty, binary resolvable on PATH) before calling execute().
- Log the exact command and its stderr so a failure is reproducible; avoid bare 'except:' that hides the root cause.
- For commands that touch the network (docker pull, gradle download), consider a bounded retry with exponential backoff.
When it happens
Trigger: Any call to execute(cmd) where cmd is a list passed to subprocess.run and the spawned process exits non-zero. In this repo that means docker buildx create (line 54 of docker_release.py), docker buildx rm (line 57), or the inner execute() inside build_docker_image_runner (common.py:44).
Common situations: docker buildx not installed or not enabled, docker daemon not running, builder name 'kafka-builder' already exists (on create) or already removed (on rm), network/proxy issues pulling base images, disk full, or a malformed Dockerfile/build context path.
Related errors
- Docker Image Build failed
- Docker image push failed
- Unexpected contents in the artifact. Exactly one version dir
- This field cannot be empty
- GITHUB_TOKEN is not set in the environment
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/a84a8bf7d624887a.json.
Report an issue: GitHub.