Repository navigation
Conversation
Lancetnik
marked this pull request as ready for review
November 23, 2026 05:10
Lancetnik
force-pushed
the
stack/tombstone-fastapi-batch
branch
from
November 23, 2026 19:10
82ab5c8 to
6989a9a
Compare
IvanKirpichnikov
requested changes
Nov 25, 2026
Comment on lines
+369
to
+385
| def _accepts_nullable_model_items(field: "ModelField") -> bool: | ||
| annotation = ( | ||
| field.field_info.annotation if FASTAPI_V2 else getattr(field, "outer_type_", None) | ||
| ) | ||
| annotation = _unwrap_annotated(annotation) | ||
| if get_origin(annotation) in {Union, UnionType}: | ||
| types = tuple(arg for arg in get_args(annotation) if arg is not type(None)) | ||
| if len(types) != 1: | ||
| return False | ||
| annotation = _unwrap_annotated(types[0]) | ||
| if get_origin(annotation) not in {list, Sequence}: | ||
| return False | ||
| items = get_args(annotation) | ||
| if not items: | ||
| return False | ||
| item = _unwrap_annotated(items[0]) | ||
| return type(None) in get_args(item) and _is_model_annotation(item) |
Collaborator
Comment on lines
+165
to
+179
| def get_tombstone_body( | ||
| message: "StreamMessage[Any]", decoded: Any | ||
| ) -> TombstoneBody | None: | ||
| if not message.uses_default_decoder: | ||
| return None | ||
| if not message.has_body and _is_empty_body(decoded): | ||
| return TombstoneBody() | ||
|
|
||
| missing = message.batch_body_missing | ||
| if isinstance(decoded, list) and len(decoded) == len(missing) and any(missing): | ||
| return TombstoneBody([ | ||
| None if absent and _is_empty_body(item) else item | ||
| for item, absent in zip(decoded, missing, strict=True) | ||
| ]) | ||
| return None |
Collaborator
There was a problem hiding this comment.
Rearranging the decoded batch in middleware violates the list[Model | None] binding. If consume_scope expands the list from await msg.decode(), the tombstones mask remains in its original order. On both TestBroker got a validation error on b"" instead of [None, Model(...)]
This branch has not been deployed
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
Bind tombstone positions to
Nonein a default-decodedlist[Model | None]. Keep empty bytes inlist[bytes]and preserve a custom decoder’s results.Layer 7 of 7. The diff contains 127 added and removed lines, including tests and docs. Derived from #3028 and #3379.
Evidence
The shared FastAPI tests cover mixed batches through both Test brokers and verify nullable models, bytes, and custom decoding.
AI assistance
Codex prepared and tested this layer from the earlier tombstone work.