Skip to content

chore: replace archived hamba/avro with confluent-avro-go - #414

Merged
mostafa merged 1 commit into
mainfrom
chore/confluent-avro-go
Sep 8, 2026
Merged

chore: replace archived hamba/avro with confluent-avro-go#414
mostafa merged 1 commit into
mainfrom
chore/confluent-avro-go

Conversation

@mostafa

@mostafa mostafa commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

hamba/avro is archived and unmaintained. This PR swaps it for confluent-avro-go (v2.32.0), Confluent's maintained fork that continues the hamba v2 line and powers confluent-kafka-go's own Schema Registry Avro serde — the same Kafka client library xk6-kafka ships, so our wire behavior stays aligned with Confluent's serde by construction.

Due diligence: fork vs hamba v2.31.0 (our pinned version)

File-by-file diff of the two modules:

File Delta
codec_union.go, resolver.go, config.go, decoder.go, encoder.go byte-identical — every behavior we depend on is preserved
schema.go import-path rename only
reader.go endianness-safety fix (unsafe pointer cast → binary.LittleEndian)
rest test import renames, CI/metadata

Our Avro test suite encodes the full behavioral contract (wrapped union maps, int.date discriminators, nullable-union bare slices, resolver decode envelopes, logical types, bytes/fixed conversion) and passes unchanged.

Alternatives considered

twmb/avro (v1.9.0, actively maintained): a modern rewrite with schema evolution (Resolve/CheckCompatibility), OCF, single-object encoding, schema-aware JSON, and native float64int32 coercion that could eventually replace our convertFloat64ToIntForIntegerFields layer. However, it has a completely different API (SchemaNode introspection, different union defaults and branch naming), so adopting it means rewriting and re-verifying the entire conversion layer for features xk6-kafka does not use today. It also started in Jan 2026 with a single maintainer, whereas the fork is battle-tested hamba code under corporate maintenance.

Changes

  • go.mod: github.com/hamba/avro/v2 v2.31.0github.com/confluentinc/confluent-avro-go/v2 v2.32.0
  • Import path swap in avro.go, schema_registry.go and the three Avro test files (package name is avro in both — no code changes)
  • Doc/comment reference updates (README, schema-registry.md, v2.2.0-subcommand.md, complex-schema script)

Verification

  • go build ./..., go vet, gofmt/goimports clean, golangci-lint run: 0 issues
  • Full CGO_ENABLED=1 go test ./... -race against a live Kafka + Schema Registry: pass

No behavior changes; not a breaking change.

hamba/avro is archived and unmaintained. Confluent maintains a fork
(github.com/confluentinc/confluent-avro-go) that continues the v2 line
and powers confluent-kafka-go's Schema Registry Avro serde — the same
client library xk6-kafka ships, keeping wire behavior aligned.

The fork is a drop-in replacement: codec_union.go, resolver.go,
config.go, decoder.go and encoder.go are byte-identical to hamba
v2.31.0; schema.go differs only by the import rename, and reader.go only
by an endianness-safety fix. This change is the import-path swap
(v2.31.0 -> v2.32.0) plus doc reference updates; no behavior changes.

Also evaluated twmb/avro (v1.9.0): a capable rewrite with schema
evolution, OCF, single-object encoding and native float64 coercion, but
adopting it would require rewriting the conversion layer and
re-verifying union semantics, for features xk6-kafka does not use.
@mostafa
mostafa merged commit 4eb84eb into main Sep 8, 2026
9 checks passed
@mostafa
mostafa deleted the chore/confluent-avro-go branch September 8, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant