Skip to content

Fix rate limit reset duration parsing#407

Open
SatorSK wants to merge 1 commit into
CortexLM:mainfrom
SatorSK:fix-ratelimit-reset-duration
Open

Fix rate limit reset duration parsing#407
SatorSK wants to merge 1 commit into
CortexLM:mainfrom
SatorSK:fix-ratelimit-reset-duration

Conversation

@SatorSK
Copy link
Copy Markdown

@SatorSK SatorSK commented May 20, 2026

Fixes PlatformNetwork/bounty-challenge#52868.

Summary

  • Parse rate-limit reset headers as duration strings such as 1s, 1m30s, and 6m0s
  • Treat small integer reset values as seconds from now while preserving large Unix timestamp values
  • Add a reset-token fallback and focused unit coverage

Why

parse_rate_limit_headers() previously parsed x-ratelimit-reset-requests only as a Unix timestamp. Providers can return reset values as durations, for example OpenAI-style 60s / 1m30s or plain integer seconds. Those values were silently ignored, leaving reset_at unset and preventing display/retry code from knowing when the window resets.

Verification

  • cargo fmt --package cortex-ratelimits --check
  • cargo test -p cortex-ratelimits

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants