Repository navigation
Handle expected Twitch ban rejections without agent alerts - #1745
Merged
Merged
Conversation
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.
The Agent issues alert recorded an authenticated Twitch
/banrequest on 2026-10-28 at 22:51:55 UTC: Twitch returned HTTP 400, but the agent returned HTTP 500/INTERNAL and emitted an Error Reporting event. The existing log does not retain Twitch's response message, so the exact rejection in that incident cannot be recovered.Recognize known ban-state rejections (already banned, not banned, and protected targets) and return a callable
failed-preconditionwith a fixed, safe message. These responses use HTTP 400 and informational request logs. Unknown 400s, missing-parameter errors, permission failures, transport errors, and 5xx responses retain error reporting. The moderation lookup also returnsnot-foundbefore submitting an invalid ban/unban/timeout request when Twitch returns no matching user.The room-readiness test keeps its fake connection open until its assertion completes, so cancellation cannot race with connection completion.
Regression tests exercise the callable protocol through the real Twitch client, verify reporting severity and response-body redaction, retain existing rate-limit behavior, and check that missing users cause no moderation request. Validation passed:
CI=true TWITCH_CLI=/tmp/rtchat-twitch-cli/twitch go test -race ./...,go vet ./..., andgit diff --check. The room-readiness fixture also passed 1,000 race-enabled repetitions.Twitch documents these HTTP 400 ban-state rejections: https://dev.twitch.tv/docs/api/reference/#ban-user and https://dev.twitch.tv/docs/api/reference/#unban-user.