Repository navigation
Conversation
Honor the supplied event format before checking ce- headers, as required by the HTTP binding sections 3 and 3.2.3. Assisted-by: ChatGPT (Codex) Signed-off-by: Sonam <120879799+BiNKss7@users.noreply.github.com>
Cover redundant metadata headers, Content-Type casing and parameters, explicit and inferred factories, partial metadata, and custom formats. All eight regression cases fail without the source fix. Assisted-by: ChatGPT (Codex) Signed-off-by: Sonam <120879799+BiNKss7@users.noreply.github.com>
Document the corrected precedence of structured Content-Type over redundant metadata headers. Assisted-by: ChatGPT (Codex) Signed-off-by: Sonam <120879799+BiNKss7@users.noreply.github.com>
EmiRZx
reviewed
Nov 30, 2026
EmiRZx
left a comment
There was a problem hiding this comment.
kafka.from_kafka has the same precedence: any ce_ header selects binary mode. Kafka binding section 3 also picks the mode by content-type, and 3.3.3 allows metadata headers in structured mode. A Kafka message with content-type: application/cloudevents+json, a valid JSON body and a ce_subject header fails with CloudEventValidationError. from_amqp and from_rabbitmq already check the content type first.
xSAVIKx
reviewed
Dec 2, 2026
Comment on lines
+304
to
+313
| # Structured messages may also carry ce- metadata headers (HTTP binding 3.2.3). | ||
| # Their Content-Type determines the mode; the body remains authoritative. | ||
| content_type = next( | ||
| ( | ||
| value | ||
| for key, value in message.headers.items() | ||
| if key.lower() == CONTENT_TYPE_HEADER | ||
| ), | ||
| "", | ||
| ) |
Member
There was a problem hiding this comment.
I think this belongs to the HTTPMessage class. please extract this as get_content_type() -> str | None.
Comment on lines
+314
to
+317
| if ( | ||
| content_type.partition(";")[0].strip().lower() | ||
| == event_format.get_content_type().partition(";")[0].strip().lower() | ||
| ): |
Member
There was a problem hiding this comment.
let's move .partition(";")[0].strip().lower() to a named helper.
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #314.
Type of change: Bug fix
Description:
The core HTTP decoder selects binary mode whenever it sees a
ce-*header. A structured request with redundant metadata headers therefore uses the header attributes and treats its envelope as data. A lonece-subjectheader can instead make a valid structured event fail validation.Check Content-Type against the supplied event format before inspecting metadata headers. Match media types case-insensitively and without parameters, including custom formats. Preserve existing fallback behavior. This follows HTTP binding section 3 and section 3.2.3, which permits metadata headers on structured messages.
Correct the mixed-headers test that asserted binary precedence, and cover explicit/auto-detected factories, casing, parameters, partial metadata, and a custom format. Include a changelog entry. No dependencies or public APIs change.
Validation (Linux, CPython 3.12.14):
socksioand localhost proxy exclusions in the test environment; project dependencies were not changed.Checklist: