Skip to content

fix(json): treat null attributes as omitted when decoding - #309

Open
zhanghao0806 wants to merge 1 commit into
cloudevents:mainfrom
zhanghao0806:fix/json-null-attributes
Open

zhanghao0806 wants to merge 1 commit into
cloudevents:mainfrom
zhanghao0806:fix/json-null-attributes

Conversation

@zhanghao0806

Copy link
Copy Markdown
Contributor

Description

Treat JSON envelope attributes whose value is null as omitted before version detection, time parsing, and event construction. The core JSON reader previously passed them to validation (or isoparse for time), rejecting JSON representations permitted by the specification.

Related to the JSON decoding distinction discussed in #199. This does not change Python object equality or in-memory attribute validation.

Specification: https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md#22-type-system-mapping

Validation

  • Before the fix: 11 new regression cases failed.
  • Full pytest -q: 886 passed, 18 xfailed.
  • Ruff lint/format and MyPy on both changed files: passed.
  • Covers optional context attributes and extension attributes, explicit and auto-detected factories, a custom factory, null payloads, and nested payload null/false/zero values.

Only top-level null values are removed; payload contents are preserved. Prepared with AI assistance; commits are signed off.

Signed-off-by: zhanghao <112082360+zhanghao0806@users.noreply.github.com>
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