Skip to content

ratelimit: parse Retry-After HTTP dates in IMF-fixdate format - #1216

Merged
ggreer merged 1 commit into
ConductorOne:mainfrom
Mohith26:fix/retry-after-http-date
Nov 4, 2026
Merged

ggreer merged 1 commit into
ConductorOne:mainfrom
Mohith26:fix/retry-after-http-date

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

parseTime in pkg/ratelimit/http.go handles non-numeric reset values with time.RFC850 and then time.RFC3339. The usual HTTP-date form for Retry-After is IMF-fixdate (Sun, 06 Nov 1994 08:49:37 GMT, RFC 9110 section 5.6.7), and neither layout accepts it. So a 429 with Retry-After: <IMF-fixdate> fails to parse, ExtractRateLimitData skips the header, and the connector gets the 60 second default instead of the server's reset time.

This switches the first attempt to http.ParseTime, which accepts IMF-fixdate, RFC 850 and ANSI C, and keeps the RFC3339 fallback.

Testing:

  • Added TestExtractRateLimitData_RetryAfterHTTPDate covering all three HTTP-date formats on a 429. The IMF-fixdate and ANSI C cases fail on main (reset comes back as now+60s) and pass with the change.
  • go test ./pkg/ratelimit/ ./pkg/uhttp/ passes.
  • golangci-lint run ./pkg/ratelimit/... reports 0 issues.

I used AI assistance while writing this and checked the change and tests by hand.

parseTime tried time.RFC850 and time.RFC3339 for non-numeric reset
values. RFC 9110 HTTP dates are usually IMF-fixdate
("Sun, 06 Nov 1994 08:49:37 GMT"), which neither layout accepts, so a
429 with an HTTP-date Retry-After fell back to the 60 second default.

Use http.ParseTime, which accepts IMF-fixdate, RFC 850 and ANSI C, and
keep the RFC3339 fallback.
@Mohith26
Mohith26 requested a review from a team November 3, 2026 09:06
@ggreer
ggreer merged commit 8cdf554 into ConductorOne:main Nov 4, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants