Skip to content

connector: map Reddit failures to statuses, RespErrors and human state messages - #6

Merged
Fizzadar merged 7 commits into
mainfrom
indent/reddit-error-reporting
Oct 19, 2026
Merged

Fizzadar merged 7 commits into
mainfrom
indent/reddit-error-reporting

Conversation

@Fizzadar

Copy link
Copy Markdown
Contributor

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.ExtractRedditError that maps failures to message statuses or RespErrors with real reasons, permanence and short human messages, and moves raw error text into Info. It also stops the sync loop in LogoutRemote (mautrix v0.30.0 doesn't disconnect after a remote logout) and adds timeouts to the Reddit session HTTP clients.

View in Indent
Tag @indent to continue the conversation here.

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
indent Bot force-pushed the indent/reddit-error-reporting branch from d83f73c to e2fb857 Compare October 19, 2026 14:31
@Fizzadar
Fizzadar marked this pull request as ready for review October 19, 2026 15:18
@indent

indent Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Issues

All clear! No issues remaining. 🎉

1 issue already resolved
  • Permanently rejected Reddit requests (4xx other than 401/403/429, and unbridgeable media uploads) are marked Fail but carry the network_error reason, so clients show a connectivity-style error and imply a retry that can't succeed. Use a generic or unsupported reason instead. (fixed by commit ac06126)
    Found by Indent Review Agent

CI Checks

All CI checks passed on ac06126.

Review agents

Select any unchecked box below to run or rerun that agent.

Passed (1)
  • Indent Review Agent · The nit is fixed and the incremental diff introduces no new problems.
Full results

Indent Review Agent

  • Summary: The nit is fixed and the incremental diff introduces no new problems.
  • Last ran on commit: ac061263
  • Latest result
    {
      "summary": "The nit is fixed and the incremental diff introduces no new problems.",
      "findings": []
    }

@Fizzadar
Fizzadar merged commit 680540a into main Oct 19, 2026
11 checks passed
@Fizzadar
Fizzadar deleted the indent/reddit-error-reporting branch October 19, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant