Skip to content

fix(channels): Discord REST client missing 429 rate-limit handling #4728

@bug-ops

Description

@bug-ops

Description

The Discord REST client (crates/zeph-channels/src/discord/rest.rs) uses .error_for_status()? to surface HTTP errors but has no handling for HTTP 429 (Too Many Requests) responses from the Discord API.

Discord's rate-limiting system returns a Retry-After header (in seconds) on 429 responses. Without handling this, the bot will permanently fail the current message send/edit and surface an error to the user rather than backing off and retrying.

By contrast, the Telegram adapter explicitly clamps stream_interval_ms to avoid hitting Telegram's rate limits (line 218 in telegram.rs).

Expected Behavior

On HTTP 429, the Discord REST client should:

  1. Parse the Retry-After header (or response body retry_after field)
  2. Sleep for that duration (or a bounded maximum)
  3. Retry the request up to a configured limit

Actual Behavior

HTTP 429 is surfaced as a generic reqwest::Error via error_for_status(), causing the message operation to fail permanently.

Affected code

crates/zeph-channels/src/discord/rest.rs:96  .error_for_status()?
crates/zeph-channels/src/discord/rest.rs:118 .error_for_status()?

Environment

Metadata

Metadata

Assignees

Labels

P3Research — medium-high complexitybugSomething isn't workingchannelszeph-channels crate (Telegram)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions