🐛 Materialize iterable middleware arguments before inspecting them - #617
Merged
Conversation
`_build_parse_stack` and `_build_unparse_stack` iterated the passed `append_middleware`/`prepend_middleware` once to compute the middleware types and then again to build the stack. With a generator or any other one-shot iterator (both are valid `Iterable[Middleware]`, as the public signatures promise) the second pass saw nothing and the middleware was silently dropped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
Author
|
lgtm |
The unparse builder's warning was copied from the parse builder and still mentioned `append_middleware` / `parse_stack`, which do not exist on the write path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
MiWeiss
force-pushed
the
fix/iterable-middleware-arguments
branch
from
September 3, 2026 21:22
c7d9543 to
95ff0c5
Compare
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.
append_middleware/prepend_middlewareare typedIterable[Middleware], but the stack builders iterate the argument twice — once to compute middleware types for the duplicate warning, once to build the stack. A generator or other one-shot iterator is exhausted by the first pass, so the middleware is silently dropped.Fix: materialize both arguments to lists at the top of
_build_parse_stackand_build_unparse_stack, before anything inspects them. Public annotations stayIterable; they are now actually honoured.Tests: 9 regression tests over the public entry points (
parse_string,parse_file,write_string,write_file) with generators. Suite: 2739 passed, 12 skipped (was 2730 + 12).Fixes #531
🤖 Generated with Claude Code