display promo message in usage error (#10285)

If a promo message is attached to a rate limit response, then display it
in the error message.
This commit is contained in:
willwang-openai
2026-02-01 01:13:25 +09:00
committed by GitHub
parent 8660ad6c64
commit 2a299317d2
3 changed files with 60 additions and 7 deletions

View File

@@ -41,6 +41,14 @@ pub fn parse_rate_limit(headers: &HeaderMap) -> Option<RateLimitSnapshot> {
})
}
/// Parses the bespoke Codex rate-limit headers into a `RateLimitSnapshot`.
pub fn parse_promo_message(headers: &HeaderMap) -> Option<String> {
parse_header_str(headers, "x-codex-promo-message")
.map(str::trim)
.filter(|value| !value.is_empty())
.map(std::string::ToString::to_string)
}
fn parse_rate_limit_window(
headers: &HeaderMap,
used_percent_header: &str,