Skip to content

feat(model-avro): re-platform converter onto common-avro + common-json#1909

Open
jfallows wants to merge 2 commits into
developfrom
claude/festive-goodall-0uwfo0
Open

feat(model-avro): re-platform converter onto common-avro + common-json#1909
jfallows wants to merge 2 commits into
developfrom
claude/festive-goodall-0uwfo0

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Fixes #1856.

Re-platforms the model-avro converter off the shaded Apache Avro + Jackson whole-message GenericRecord/JSON path onto the format-native common-avro library (#1838/#1884) for the Avro side and the common-json transcoder (#1855) for the JSON side, surfaced through the engine model SPI.

common-avro — canonical union mode

Adds a canonical (flattened nullable-single union) mode to the AvroJson bridge:

  • AvroJson.parser/stream/generator(schema, ..., canonical) — when canonical is true, a union of null and exactly one other type encodes/decodes as a bare JSON value (null or the unwrapped value) instead of the {"<branch>": value} wrapper. Every other union shape is unchanged.
  • This is what lets model-avro's view: json keep its existing key=value semantics for ["null", T] unions, matching the prior CanonicalJsonEncoder.
  • Covered by new AvroJsonTest cases.

model-avro — re-platform

  • AvroRead/AvroWrite converters drive the common-avro AvroJson streaming pipelines (avro↔JSON, canonical) for view: json; the schema is resolved via CatalogHandler, compiled to an AvroSchema, and cached per schemaId alongside its pull parser.
  • Validation and $.field extraction run on the common-avro streaming pull parser (zero-copy segments for string/bytes/fixed); a decode/validation failure aborts via engine RESET.
  • Drops the shaded Apache Avro + Jackson dependencies, the shade plugin, and the org.apache.avro.io.* classes; depends on common-avro + common-json; NOTICE regenerated.
  • Preserves existing model: avro config, view: json semantics, JSON padding, and field extraction. The validation-failed event now carries the common-avro decode error, mirroring the model-json re-platform precedent (EventIT + event.yaml updated accordingly).

Testing

Full clean install with k3po integration tests is green for model-avro.spec, common-avro, and model-avro: unit tests, EventIT, JaCoCo coverage, Checkstyle, license, and NOTICE checks all pass.

Notes

  • Verified build was scoped to the affected modules. The public API (io.aklivity.zilla.runtime.model.avro.config) is unchanged, so dependents (docker image, bindings using the avro model) are not expected to be affected.
  • The spec's expected validation event now includes the literal truncated datum error string from common-avro; if that wording changes upstream the spec expectation needs a matching update — the same coupling model-json already has.

🤖 Generated with Claude Code

https://claude.ai/code/session_012CLYLdgT4B97uSUndTsG6N


Generated by Claude Code

claude added 2 commits June 16, 2026 22:15
Re-platform the model-avro converter off the shaded Apache Avro + Jackson
whole-message GenericRecord/JSON path onto the format-native common-avro
library and the common-json transcoder, surfaced through the engine model SPI.

- AvroRead/AvroWrite converters drive the common-avro AvroJson streaming
  pipelines (avro<->JSON) for view: json; schemas are resolved via
  CatalogHandler and the compiled AvroSchema + parser cached per schemaId.
- Validation and field extraction run on the common-avro streaming pull
  parser (zero-copy segments for string/bytes/fixed), aborting via engine
  RESET on a decode/validation failure.
- Add a canonical (flattened nullable-single union) mode to the common-avro
  AvroJson parser/stream/generator so view: json keeps the existing
  key=value encoding for [null, T] unions; every other union shape is
  unchanged.
- Drop the shaded Apache Avro + Jackson dependencies, the shade plugin, and
  the org.apache.avro.io.* classes; depend on common-avro + common-json and
  regenerate NOTICE.
- Preserve existing model: avro config, view: json semantics, padding, and
  field extraction; the validation-failed event now carries the common-avro
  decode error, mirroring the model-json re-platform.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CLYLdgT4B97uSUndTsG6N
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.

model-avro: streaming converter on common-avro + common-json transcoder

2 participants