Skip to content

[CHA-0] fix: read rate limit headers case-insensitively; poll in hide/show test - #243

Merged
nijeesh-stream merged 2 commits into
masterfrom
fix/cha-0-flaky-ci-tests
Oct 15, 2026
Merged

nijeesh-stream merged 2 commits into
masterfrom
fix/cha-0-flaky-ci-tests

Conversation

@nijeesh-stream

@nijeesh-stream nijeesh-stream commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

🧪 Test & lint fails on every PR (e.g. docs-only #241) and on the scheduled master runs. This PR fixes two of the three causes. One is a real SDK bug: with the async client, StreamResponse.rate_limit() returns None. The other is a test race. Risk is low: rate_limit() now finds the headers whatever their case, and headers() is unchanged.

Ticket

Summary

  1. async_chat/test_client.py::test_stream_response: 'NoneType' object has no attribute 'limit'. StreamChatAsync._parse_response passes dict(response.headers), which loses aiohttp's case-insensitive lookup. The server now sends X-Ratelimit-Limit etc., so headers.get("x-ratelimit-limit") misses. The sync client passes the requests case-insensitive dict, so it was unaffected. StreamResponse now looks these headers up case-insensitively. A new offline unit test (test_stream_response_headers.py) fails without the change.
  2. test_channel_hide_show (sync and async): assert 0 == 1 on the last assertion. When a message is sent, the backend unhides the channel for other members in a background task (ShowChannelForAllUsersAsync), not inline. The tests now poll query_channels for up to 30s (10s was not always enough for the async test on the shared app).

Not fixed here: test_delete_channels (task did not succeed) fails intermittently on master. The task result shape is unchanged ({"status": "ok"}), so the task either errors or takes longer than 300s on the shared test app. Finding out which needs access to the test app's task results.

Checklist

  • black, mypy clean (flake8 only reports a pre-existing B042 in base/exceptions.py, from a newer flake8-bugbear than CI pins)
  • The changed code has been covered with unit tests
  • The internal documentation (./docs) has been updated (n/a)

🤖 Generated with Claude Code

The async client passes response headers as a plain dict, which keeps the
case the server sent, so rate_limit() returned None when the server sent
X-Ratelimit-* instead of x-ratelimit-*. Also poll in test_channel_hide_show:
the backend unhides a channel in a background task after a new message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nijeesh-stream

Copy link
Copy Markdown
Contributor Author

Update after CI: the async test_channel_hide_show still failed on 3.8 and 3.12 with a 30s poll, and test_delete_channels still times out. The sync hide/show test and test_stream_response now pass. Both remaining failures wait on a backend async task (channel unhide, delete channels). stream-chat-go's TestClient_DeleteUsers timed out after 60s at the same time (GetStream/stream-chat-go#405). This points to slow or stuck task processing on the shared CI app's backend shard rather than test timing; someone with access to that app needs to check it. The rate-limit header fix in this PR stands on its own.

@nijeesh-stream
nijeesh-stream enabled auto-merge (squash) October 15, 2026 09:39
@nijeesh-stream
nijeesh-stream merged commit 24c93b2 into master Oct 15, 2026
9 of 15 checks passed
@nijeesh-stream
nijeesh-stream deleted the fix/cha-0-flaky-ci-tests branch October 15, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants