Skip to content

python: Preserve structured JSON payload objects - #722

Merged
clemensv merged 1 commit into
mainfrom
fix/structured-json-0114-a392eeae
Nov 29, 2026
Merged

clemensv merged 1 commit into
mainfrom
fix/structured-json-0114-a392eeae

Conversation

@clemensv

@clemensv clemensv commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Change

Restore JSON values in the structured CloudEvents data member. The published 0.11.3 producer passes serialized bytes to the formatter, so existing JSON consumers receive data_base64 instead of their previous object-data shape.

The SDK's base64 encoding is legal CloudEvents JSON. This repair preserves producer compatibility; it does not relax receiver assertions.

  • Decode JSON before structured formatting and use the identity data marshaller.
  • Preserve non-JSON structured Avro base64 and binary-mode payload bytes.
  • Correct the inherited-media-type test, which previously required base64 even for JSON.
  • Cover explicit and default structured mode, JSON parameters and untyped +json payloads.
  • Document the generated producer's payload representation.

The formatter correction reuses the bounded Kafka hunk from open #712 at 439f7a7a7ad512ed461cf483e574dacf689e5112. It does not include or supersede that PR's remaining generated-type, MQTT or generated-test argument changes.

Validation

Local validation used isolated Python 3.11.9, actual PyPI Avrotize 3.9.8, CloudEvents 1.13.0 and native Proton 0.40.0. $py denotes that isolated executable.

& $py -m pytest test\py\test_python.py -k 'python_producer_inherited_avro_content_type or kafkaproducer_untyped_structured_json_media_types' --no-header -q

Before the template repair: 3 failed, 1 passed. All three failures are missing data members, including canonical JSON and untyped +json with/without parameters. An earlier exploratory typed +json case hit the existing datatype serializer limitation and is not counted as this regression's red proof.

& $py -m pytest test\py\test_python.py -k 'python_producer_inherited_avro_content_type or kafkaproducer_untyped_structured_json_media_types or honors_inherited_id_on_encoded_message or rejects_explicit_empty_id or versioned_dataschema_on_wire or producer_identity_subject_and_key_encoding or binary_marshaller' --no-header -q

After repair: 35 passed, 104 deselected. One unchanged optional pytest-asyncio configuration warning is retained. Full output was saved under the repository's tmp directory.

  • Local generator import: PASS, source origin verified.
  • py_compile on the focused generated projects and changed test module: 292 files passed.
  • git diff --check: PASS.
  • gh run watch 46226498342 --repo xregistry/codegen --exit-status --interval 30: PASS, exit 0. All eight suites passed: core, Rust, C#, Java, Java RabbitMQ, TypeScript, other and Go.
  • gh pr checks 722 --repo xregistry/codegen --json name,bucket,state,link: PASS, all eight suites and DCO green; the dependency auto-merge job is an expected skip.
  • Qualified PR head: 8411dec8b29b4487800bd0d53bd4c7183c5838d5, tree f3e7b5161bdc0e3c9b7de83421c7aaedd6e7df70. Current main remains c48d405cd841483800a078da9a2c8aab3cd4d32a.
  • Accepted-main qualification and the fresh immutable 0.11.4 publication are pending, not claimed by PR or local results.

Release boundary

The user approved normal CLI release gates for a fresh immutable 0.11.4 after acceptance on current main. Published 0.11.3 tags/assets will not be overwritten. The expired Marketplace credential in #721 remains outside that CLI-only scope.

Closes #701.
Refs #712 and clemensv/real-time-sources#1743.

Keep JSON payloads as JSON values in the structured CloudEvents data member.
Retain base64 for non-JSON structured payloads and raw binary-mode bytes.
Correct the inherited-media-type regression's JSON expectation and cover
default structured mode, media-type parameters and untyped +json payloads.

Refs: #701

Signed-off-by: Clemens Vasters <clemens@vasters.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@clemensv
clemensv merged commit bb8eb63 into main Nov 29, 2026
10 checks passed
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.

Python Kafka structured JSON regresses from data object to data_base64

1 participant