Skip to content

fix: handle optional CloudEvents data content types - #4698

Open
gabisonia wants to merge 1 commit into
BrighterCommand:masterfrom
gabisonia:fix/4680-cloudevents-optional-content-type
Open

gabisonia wants to merge 1 commit into
BrighterCommand:masterfrom
gabisonia:fix/4680-cloudevents-optional-content-type

Conversation

@gabisonia

Copy link
Copy Markdown
Member

Description

Structured CloudEvents with omitted or null datacontenttype previously threw during unwrapping. Infer application/json when a data member is present, preserving JSON strings and explicit JSON null. Use application/octet-stream for base64 payloads or events without data, since Brighter requires a content type even when the CloudEvent omits it.

Track whether data was present so an explicit null payload remains distinct from an absent payload. Decode empty base64 payloads as binary and give the extracted body the resolved content type without mutating the header's content type.

Adds 48 regression cases covering sync/async unwrapping, omitted/null content types, all JSON value kinds, arbitrary and JSON-looking binary bytes, empty binary payloads, and absent payloads. No public signature or dependency changes.

Related Issues

Fixes #4680

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the Contributing Guide
  • I have checked the documentation for relevant guidance
  • I have added/updated XML documentation for any public API changes
  • I have added/updated tests as appropriate
  • My changes follow the existing code style and conventions

Additional Notes

  • Checked the CloudEvents JSON payload deserialization rules, including missing content types and binary payloads.
  • Before the fix, all 48 regression cases reproduced the null-content-type exception on .NET 9 and .NET 10. All pass after the fix on both runtimes.
  • Full Core suite: 1,920 passed, 7 existing skips, zero failures on each runtime after the .NET 9 rerun.
  • The first .NET 9 full run failed the existing sweeper allocation test. It also failed with the same allocation difference in three isolated runs against unchanged production code. The subsequent full run passed without changing that test or the fix.
  • Release builds pass for netstandard2.0, net8.0, net9.0, and net10.0 with zero warnings or errors.
  • Tests ran through a temporary local xUnit execution-engine runner because the environment blocks standard VSTest host sockets. The runner is not included; normal CI remains required.
  • This branch targets master independently. JSON string handling when a content type is explicitly supplied remains tracked separately in [Bug] CloudEvents unwrapping removes quotes from JSON string payloads #4681.

Please merge with a merge commit, per the contributing guide.

Infer JSON for data members when datacontenttype is absent or null, preserve explicit null payloads, and use an opaque content type for binary or absent payloads. Add 48 sync and async regression cases.

Fixes BrighterCommand#4680

This branch has not been deployed

No deployments
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.

[Bug] Structured CloudEvents without optional datacontenttype fail to unwrap

1 participant