Repository navigation
Conversation
`parsed_consumer()` always wraps the decoded body as `{first_arg: body}`,
so `solve_dependencies()` never sees an absent body - only a present dict
like `{"msg": None}`. It can't take the no-body shortcut it already uses
for bodyless HTTP requests, so a required field on the target model fails
validation before the handler runs. On a compacted topic that's every
tombstone, forever.
A tombstone is a property of the record ("this record has no value"), not
a value in the body slot, so it's carried as a flag on `StreamMessage`:
the kafka/confluent parsers set `tombstone=value is None`, `route.py`
passes `body=None` to `solve_dependencies` when it's set. `body` stays
`b""`, so `decode_message`, the telemetry providers, the testing brokers
and the producers are untouched and `msg: bytes` handlers are unaffected.
Other brokers never set the flag, so a plain `b"null"` payload on
Rabbit/NATS keeps its existing behavior.
Closes #1967
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoFxdJYipYjPtMdmJaxCFN
Review asked for the core flag to stop carrying a Kafka noun. What `route.py` decides is whether the message has a body at all - the same question FastAPI already answers for a bodyless HTTP request - so `StreamMessage` takes `no_body` and the other brokers get a flag that could mean something to them. The domain word lives one layer down: `KafkaMessage.tombstone` is a property over `no_body` in both `faststream/kafka/message.py` and `faststream/confluent/message.py`, so someone consuming a compacted topic still writes `msg.tombstone` and the docs note stays accurate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…atch does Confluent already had a connected test driving `value=None` straight through the raw producer, so the "a tombstone from any client, not only `publish(None)`" claim was only proven for one of the two brokers. aiokafka now has the mirror. The docs note also promised more than the code delivers: `parse_batch` never sets the flag, so `msg.tombstone` is always `False` in a `batch=True` subscriber. Said so, rather than leaving a compacted-topic consumer to find out. Per-record tombstones in a batch stay out of scope here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Keep the tombstone implementation and typed regression tests from #2933. Await both producer calls and verify received records independently of partition delivery order.
Lancetnik
marked this pull request as ready for review
November 22, 2026 19:57
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.
Summary
Carry #3028 into the lower layer of the Kafka tombstone stack. Kafka and Confluent distinguish a native null from zero bytes. The default FastAPI binding passes
Noneto the standard optional-model handler. The upper layer carries the explicit publish marker and per-record batch metadata from #3379.Evidence
This branch points at the reviewed #3028 head,
fad698650d. On FastAPI 0.162.0, the standard optional-model case passes. Embedded body binding and previously working bytes-body signatures still need the compatibility fixes identified in review.Merge Danger
The binding change can reject tombstones before a subscriber runs. Before merge, cover embedded and dependency bodies and confirm that previously valid bytes and required-model handlers still work on both Kafka backends.
AI assistance
The original implementation used Claude Code. Codex assembled the stack and verified the branch against #3028.