feat(errors): surface rate-limit headers on HTTP 429 failures - #763
Merged
Conversation
Typed SDK commands discard response headers, leaving automation blind to which Datadog rate-limit rule triggered a 429. Capture X-RateLimit-* via SDK middleware and raw HTTP helpers, print readable rule/limit/remaining details on stderr, and exit with code 429. Closes #747 Co-authored-by: Cursor <cursoragent@cursor.com>
When --verbose is set, successful typed commands emit captured X-RateLimit-* metadata to stderr using the same format as --output (json, yaml, table, csv, tsv), including the agent-mode JSON envelope. Co-authored-by: Cursor <cursoragent@cursor.com>
This comment has been minimized.
This comment has been minimized.
Browser WASM compiles formatter via lib.rs, which does not include the rate_limit module. Skip verbose rate-limit printing in browser builds. Co-authored-by: Cursor <cursoragent@cursor.com>
jack-edmonds-dd
approved these changes
Aug 25, 2026
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.
Summary
X-RateLimit-*response headers from typed SDK commands (via middleware), raw HTTP helpers, andpup apiCloses #747
Changes
src/rate_limit.rs— header extraction, formatting, exit-code selection, and unit testssrc/client.rs—RateLimitCaptureMiddlewareon the SDK reqwest clientsrc/raw_client.rs—HttpError.rate_limitfield populated from response headers; integration test with mock 429src/main.rs— central CLI error handler prints enhanced 429 output and exits 429src/commands/api.rs— store rate-limit headers before failing non-2xx responsesExample output
Test plan
cargo test rate_limitcargo test test_raw_get_rate_limit_includes_headerscargo clippy -- -D warningscargo fmt --checkMade with Cursor