📝 Bug: `StreamSub` warns that `no_ack` has no effect with a consumer group, but the flag is forwarded to XREADGROUP NOACK (#3126)
Describe the bug
StreamSub(..., group=..., consumer=..., no_ack=True) emitsRuntimeWarning: `no_ack` has no effect with consumer group
but the flag does have an effect: it reaches Redis as
XREADGROUP ... NOACK, so entries never enter the PEL. The warning is a leftover from a time when the flag was not forwarded.How to reproduce
from faststream.redis import RedisBroker, StreamSub
broker = RedisBroker()
@broker.subscriber(
stream=StreamSub("my-stream", group="my-group", consumer="c1", no_ack=True),
)
async def handler(msg: str) -> None:
...
Constructing the
StreamSub prints the warning. Running the app shows that the flag is honoured anyway: XPENDING my-stream my-group stays empty after messages are consumed.Expected behavior
No warning.
no_ack=True with a consumer group is a supported, documented mode ("equivalent to acknowledging the message when it is read", see docs/docs/en/redis/streams/groups.md).Observed behavior
The warning is emitted in
faststream/redis/schemas/stream_sub.py (the elif no_ack: branch under if group and consumer:), while the rest of the code base treats the flag as live:•
faststream/redis/subscriber/usecases/stream_subscriber.py passes noack=stream.no_ack to XREADGROUP;•
faststream/redis/subscriber/config.py switches the subscriber to AckPolicy.MANUAL when no_ack is set;•
faststream/redis/testing.py skips the PEL for no_ack subscribers;• #3049 added a
SetupError for claim_min_idle_time + no_ack, which only makes sense if no_ack works with groups.History
• The warning was introduced in 0.3.5 (#1048), when
no_ack was indeed not forwarded to XREADGROUP.• #2309 kept the warning and reset
no_ack = False right after it, so the flag really was ignored for a while.• 0.6.0 (#1779) dropped that reset, and
noack=stream.no_ack has been sent to Redis since, but the warning stayed.The sibling warning, "
no_ack is not supported by consumer group with last_id other than >", is a separate case and should be checked on its own: Redis documents NOACK for XREADGROUP regardless of the id, so it may be stale too.Suggested fix
Remove the
elif no_ack: warning branch in StreamSub.__init__ and add a test asserting that StreamSub("s", group="g", consumer="c", no_ack=True) raises no warning and that the subscriber calls xreadgroup with noack=True. Keep the claim_min_idle_time + no_ack SetupError as is.Environment
Reproduced on
main (commit 0307f09).#bug #good_first_issue #redis #faststream #ag2ai
sent via relator