{"record":{"id":"240b9bbf94104f92","repo":"apache/kafka","slug":"docker-image-build-failed","errorCode":null,"errorMessage":"Docker Image Build failed","messagePattern":"Docker Image Build failed","errorType":"exception","errorClass":"SystemError","httpStatus":null,"severity":"error","filePath":"docker/common.py","lineNumber":46,"sourceCode":"    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:\n        execute(command.split())\n    except:\n        raise SystemError(\"Docker Image Build failed\")\n    finally:\n        shutil.rmtree(temp_dir_path)\n","sourceCodeStart":28,"sourceCodeEnd":49,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/docker/common.py#L28-L49","documentation":"docker/common.py:build_docker_image_runner wraps execute(command.split()) in a bare `except:` and re-raises SystemError('Docker Image Build failed'). The bare except discards the underlying error entirely (no chaining, no message), so this is a lossy wrapper. It also cleans up the temp dir in a `finally`.","triggerScenarios":"The docker buildx build subprocess (for native or jvm image types) returns non-zero, causing execute() to raise, which the bare except re-wraps.","commonSituations":"Dockerfile syntax error; missing build arg (kafka_url, build_date); network failure fetching the kafka archive; buildx cache corruption; out-of-disk-space during the build.","solutions":["Re-run the exact `docker buildx build ...` command from the script output manually to see the real stderr.","Verify the kafka archive URL is reachable and the build args are correct.","Clear buildx cache: `docker buildx prune -f`.","Patch the script locally to drop the bare except (or `raise ... from e`) so the cause is preserved."],"exampleFix":"# before (library)\ntry:\n    execute(command.split())\nexcept:\n    raise SystemError(\"Docker Image Build failed\")  # cause lost\n\n# local debug\n$ docker buildx build -f <DOCKERFILE> --build-arg kafka_url=<url> --build-arg build_date=$(date +%F) <DIR>\n# real error printed to stderr\n\n# suggested fix (if you control the script)\nexcept Exception as e:\n    raise SystemError(\"Docker Image Build failed\") from e","handlingStrategy":"try-catch","validationCode":"null  # validate by running the same docker buildx build manually first","typeGuard":"null","tryCatchPattern":"try:\n    build_docker_image_runner(cmd, image_type, kafka_archive)\nexcept SystemError as e:\n    print(\"Build failed; re-running for diagnostics:\", ' '.join(cmd.split()), file=sys.stderr)\n    subprocess.run(cmd.split())  # surface real stderr\n    raise","preventionTips":["Run the docker build standalone first to capture stderr.","Prune buildx cache if builds start failing inexplicably.","Patch the script to chain the underlying exception (`raise ... from e`)."],"tags":["docker","buildx","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"}