Repository navigation
connector: map Reddit failures to statuses, RespErrors and human state messages - #6
Merged
Merged
Conversation
Matrix handlers returned raw or wrapped Reddit client errors, which became retriable statuses with no message, and user-caused rejections such as deleting a chat for everyone stayed retriable. Add wrapRedditError, built on redditchat.ExtractRedditError, to classify rate limits, expired sessions, forbidden and other permanent 4xx responses, and transient server or network failures into statuses with a reason, truthful certainty and a short human message. Permanent rejections use bridgev2 sentinels or FAIL_PERMANENT statuses, and image upload failures no longer surface the internal HTTP status text.
Unexpected login steps, invalid start-chat input and Reddit failures in ResolveIdentifier, SearchUsers and CreateGroup were plain errors, so the provisioning API answered with a bare 500 M_UNKNOWN. Return bridgev2 RespErrors built from the standard mautrix codes, and map Reddit request failures through the shared classifier to 429, 403, 400 or 502 responses with a human message while keeping the original error in the chain for logs.
The BAD_CREDENTIALS state sent when the chat token can't be refreshed put the raw refresh error in Message. Show a human message instead and move the raw error to Info. The explicit RELOGIN action stays, since the pinned mautrix version doesn't default BAD_CREDENTIALS to it yet.
Use mautrix.MUnknown.WithMessage instead of a RespError literal so the status code can't drift from the standard error code.
The pinned bridgev2 only calls LogoutRemote when logging out, not Disconnect, so the sync loop kept polling with the logged-out token. Its 401 handling could then refresh the chat token from the saved session or send bridge states for a deleted login. Disconnect before logging out of Reddit's homeserver.
The HTTP clients behind login and chat-token refresh had no timeout, so a hung Reddit response could block a login step or the sync loop's token refresh indefinitely. These are short request/response calls, so use the same 30 second timeout as the reaction image client.
indent
Bot
force-pushed
the
indent/reddit-error-reporting
branch
from
October 19, 2026 14:31
d83f73c to
e2fb857
Compare
Fizzadar
marked this pull request as ready for review
October 19, 2026 15:18
|
All clear! No issues remaining. 🎉 1 issue already resolved
All CI checks passed on
Select any unchecked box below to run or rerun that agent. Passed (1)Full resultsIndent Review Agent
|
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.
Failures in the Reddit bridge were often returned as bare errors. Sends and other Matrix actions showed up as retriable statuses with no message, even when they could never succeed. Start-chat and login errors reached clients as a 500
M_UNKNOWN, and the token-refresh bad-credentials state showed raw error text.This adds one classifier on top of
redditchat.ExtractRedditErrorthat maps failures to message statuses orRespErrors with real reasons, permanence and short human messages, and moves raw error text intoInfo. It also stops the sync loop inLogoutRemote(mautrix v0.30.0 doesn't disconnect after a remote logout) and adds timeouts to the Reddit session HTTP clients.Tag
@indentto continue the conversation here.