Skip to content

Protobuf compatibility issue with Kafka Connect 8 #157

@brunomendola

Description

@brunomendola

I'm extending the Kafka Connect 8.1.0 image to include the connector libs (v2.10.0). Here is the Dockerfile:

FROM confluentinc/cp-kafka-connect:8.1.0

USER root

RUN microdnf -y install tar

USER 1000

RUN mkdir /usr/share/java/kafka-connectors && curl -s https://api.github.com/repos/Aiven-Open/bigquery-connector-for-apache-kafka/releases/latest | awk -F\" '/browser_download_url.*.tar/{print $(NF-1)}' | xargs curl -s -L | tar -xf - -C /usr/share/java/kafka-connectors

I already have Kafka and Confluent Schema Registry in Kubernetes, and I want to consume Protobuf messages with the connector and (of course) sending them to BigQuery.

So I create the connector with the following config JSON:

{
  "name": "bigquery-sink",
  "config": {
    "connector.class": "com.wepay.kafka.connect.bigquery.BigQuerySinkConnector",
    "tasks.max": "3",

    "topics": "mytopic",

    "project": "myproject",
    "datasets": ".*=mydataset",

    "key.converter": "org.apache.kafka.connect.storage.StringConverter",

    "value.converter": "io.confluent.connect.protobuf.ProtobufConverter",
    "value.converter.schema.registry.url": "http://schema-registry-service.schema-registry.svc.cluster.local:8081",

    "autoCreateTables": "true",
    "sanitizeTopics": "true",

    "defaultDataset": "mydataset",
    "keyfile": "/var/secrets/google/GOOGLE_APPLICATION_CREDENTIALS",
    "allBQFieldsNullable": "true",

    "bigQueryRetry": "3",
    "maxWriteSize": "10000",
    "allowNewBigQueryFields": "true",
    "allowBigQueryRequiredFieldRelaxation": "true"
  }
}

When I receive the first message, Kafka Connect fails to deserialize it and logs the following error:

[2025-10-24 10:25:58,200] ERROR WorkerSinkTask{id=bigquery-sink-1} Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask)
com.google.common.util.concurrent.ExecutionError: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    io/confluent/kafka/schemaregistry/protobuf/ProtobufSchema.toProtoFile(Lcom/google/protobuf/DescriptorProtos$FileDescriptorProto;)Lcom/squareup/wire/schema/internal/parser/ProtoFileElement; @1248: invokestatic
  Reason:
    Type 'com/google/protobuf/DescriptorProtos$FileOptions' (current frame, stack[1]) is not assignable to 'com/google/protobuf/GeneratedMessage$ExtendableMessage'

Looks like an incompatibility of the Protobuf library shipped with the connector with the one already in Kafka Connect: since version 8.0.1, Kafka Connect upgraded to Protobuf 4, but the connector v2.10.0 still includes Protobuf 3 libraries.

When downgrading Kafka Connect to version 7.9.4 (the one before the Protobuf upgrade) the connector starts working perfectly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions