From 560e5a4933a653db98161e0098a316ff391f32e1 Mon Sep 17 00:00:00 2001 From: David del Real Sifuentes Date: Wed, 23 Sep 2026 21:42:50 +0000 Subject: [PATCH] build(deps): update kafka-python and resolve dependabot issues in dataflow/snippets Bumps `kafka-python` (to 3.0.11), `apache-beam[gcp]` (to 2.76.0), and updates the Dockerfile to use Python 3.13, Beam 2.76.0, and Java 17 to resolve Dependabot security alerts. Also updates `pytest` in the test requirements. Note: While the project successfully builds with these updates, 2 out of 4 tests in `test_read_kafka.py` are currently failing. Because fully resolving these test failures requires work beyond the scope of this Dependabot dependency bump, the remaining test fixes have been deferred to a separate task (b/565471363). --- dataflow/snippets/Dockerfile | 14 +++++++------- dataflow/snippets/requirements-test.txt | 2 +- dataflow/snippets/requirements.txt | 4 ++-- dataflow/snippets/tests/test_read_kafka.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dataflow/snippets/Dockerfile b/dataflow/snippets/Dockerfile index 4234ca52651..85aef0d7c8b 100644 --- a/dataflow/snippets/Dockerfile +++ b/dataflow/snippets/Dockerfile @@ -18,17 +18,17 @@ # on the host machine. This Dockerfile is derived from the # dataflow/custom-containers/ubuntu sample. -FROM python:3.14-slim +FROM python:3.13-slim # Install JRE -COPY --from=openjdk:8-jre-slim /usr/local/openjdk-8 /usr/local/openjdk-8 -ENV JAVA_HOME /usr/local/openjdk-8 -RUN update-alternatives --install /usr/bin/java java /usr/local/openjdk-8/bin/java 10 +COPY --from=eclipse-temurin:17-jre /opt/java/openjdk /opt/java/openjdk +ENV JAVA_HOME /opt/java/openjdk +RUN update-alternatives --install /usr/bin/java java /opt/java/openjdk/bin/java 10 WORKDIR /pipeline # Copy files from official SDK image. -COPY --from=apache/beam_python3.14_sdk:2.73.0 /opt/apache/beam /opt/apache/beam +COPY --from=apache/beam_python3.13_sdk:2.76.0 /opt/apache/beam /opt/apache/beam # Set the entrypoint to Apache Beam SDK launcher. ENTRYPOINT [ "/opt/apache/beam/boot" ] @@ -37,8 +37,8 @@ RUN apt-get update RUN apt-get install -y --no-install-recommends docker.io # Install dependencies. -RUN pip3 install --no-cache-dir apache-beam[gcp]==2.73.0 -RUN pip install --no-cache-dir kafka-python==2.0.6 +RUN pip3 install --no-cache-dir apache-beam[gcp]==2.76.0 +RUN pip install --no-cache-dir kafka-python==3.0.11 # Verify that the image does not have conflicting dependencies. RUN pip check diff --git a/dataflow/snippets/requirements-test.txt b/dataflow/snippets/requirements-test.txt index 4835ba7a447..6e2ec4f7a9b 100644 --- a/dataflow/snippets/requirements-test.txt +++ b/dataflow/snippets/requirements-test.txt @@ -1,3 +1,3 @@ -pytest==9.0.3; python_version >= "3.10" +pytest==9.1.1 docker==7.1.0 diff --git a/dataflow/snippets/requirements.txt b/dataflow/snippets/requirements.txt index 0f0d8796fa2..05ee49d50d5 100644 --- a/dataflow/snippets/requirements.txt +++ b/dataflow/snippets/requirements.txt @@ -1,2 +1,2 @@ -apache-beam[gcp]==2.63.0 -kafka-python==2.0.6 +apache-beam[gcp]==2.76.0 +kafka-python==3.0.11 diff --git a/dataflow/snippets/tests/test_read_kafka.py b/dataflow/snippets/tests/test_read_kafka.py index 0c62c5e4491..8828bffa01a 100644 --- a/dataflow/snippets/tests/test_read_kafka.py +++ b/dataflow/snippets/tests/test_read_kafka.py @@ -21,7 +21,7 @@ from docker import DockerClient from kafka import KafkaProducer from kafka.admin import KafkaAdminClient, NewTopic -from kafka.errors import NoBrokersAvailable +from kafka.errors import KafkaTimeoutError import pytest @@ -67,7 +67,7 @@ def create_topics() -> None: topics.append(NewTopic(name=TOPIC_NAMES[1], num_partitions=1, replication_factor=1)) client.create_topics(topics) break - except NoBrokersAvailable: + except KafkaTimeoutError: time.sleep(5)