Skip to content

Forward group_instance_id from the FastAPI Kafka router#2882

Open
00yhj22-debug wants to merge 2 commits into
ag2ai:mainfrom
00yhj22-debug:fix-fastapi-group-instance-id
Open

Forward group_instance_id from the FastAPI Kafka router#2882
00yhj22-debug wants to merge 2 commits into
ag2ai:mainfrom
00yhj22-debug:fix-fastapi-group-instance-id

Conversation

@00yhj22-debug
Copy link
Copy Markdown
Contributor

Description

Follow-up to #2871. The FastAPI KafkaRouter accepts group_instance_id in its subscriber() overload signatures, but the parameter was not included in the super().subscriber() call in faststream/kafka/fastapi/fastapi.py. As a result the value was silently dropped before reaching the underlying broker subscriber and the consumer never saw it — calling router.subscriber("topic", group_instance_id="x") on the FastAPI router had no effect.

This PR forwards group_instance_id explicitly in the super() call. The fix is a single line. I also added a fastapi-flavored regression test alongside the existing broker and KafkaRouter cases in tests/brokers/kafka/test_group_instance_id.py.

Type of change

  • Bug fix (a non-breaking change that resolves an issue)

Checklist

  • My code adheres to the style guidelines (ruff check and ruff format are clean)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation (no docs change needed — the parameter is already documented in the FastAPI router`s docstring; it just was not forwarded)
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix
  • Both new and existing unit tests pass successfully on my local environment (pytest tests/brokers/kafka/test_group_instance_id.py — all five tests pass)

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>
@00yhj22-debug 00yhj22-debug requested a review from Lancetnik as a code owner May 21, 2026 02:42
@github-actions github-actions Bot added the AioKafka Issues related to `faststream.kafka` module label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AioKafka Issues related to `faststream.kafka` module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants