Forward group_instance_id from the FastAPI Kafka router#2882
Open
00yhj22-debug wants to merge 2 commits into
Open
Forward group_instance_id from the FastAPI Kafka router#288200yhj22-debug wants to merge 2 commits into
00yhj22-debug wants to merge 2 commits into
Conversation
The FastAPI KafkaRouter's subscriber() accepted group_instance_id in its overload signatures but did not include it in the super().subscriber() call, so the value was silently dropped and the consumer never saw it. Forward group_instance_id explicitly in the super() call and add a fastapi-flavored regression test alongside the existing broker and KafkaRouter cases. This is the follow-up offered in ag2ai#2871. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lancetnik
approved these changes
May 28, 2026
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.
Description
Follow-up to #2871. The FastAPI
KafkaRouteracceptsgroup_instance_idin itssubscriber()overload signatures, but the parameter was not included in thesuper().subscriber()call infaststream/kafka/fastapi/fastapi.py. As a result the value was silently dropped before reaching the underlying broker subscriber and the consumer never saw it — callingrouter.subscriber("topic", group_instance_id="x")on the FastAPI router had no effect.This PR forwards
group_instance_idexplicitly in thesuper()call. The fix is a single line. I also added a fastapi-flavored regression test alongside the existing broker andKafkaRoutercases intests/brokers/kafka/test_group_instance_id.py.Type of change
Checklist
ruff checkandruff formatare clean)pytest tests/brokers/kafka/test_group_instance_id.py— all five tests pass)