You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: guard the debug-log type assertion and keep the rate limiter's context cause
Two small robustness fixes.
1. debugLogger asserted an interface value unconditionally.
Request: req.values[debugRequestLogKey].(*DebugLogRequest),
prepareRequestDebugInfo populates that key before the request is sent, so the
key is normally present -- but if it is not, this panics inside a logging path:
panic: interface conversion: interface {} is nil, not *resty.DebugLogRequest
Now guarded with the two-value form and an empty fallback, so debug logging can
degrade rather than take the process down.
2. Rate limiter errors erased the context cause.
Both RateLimitTokenBucket.Allow and RateLimitSlidingWindow.Allow returned the
bare ErrRateLimitExceeded sentinel whether the wait ended in cancellation or a
deadline, so callers could not tell the two apart and
errors.Is(err, context.Canceled) never matched. The context error is now wrapped
alongside the sentinel, so both checks succeed:
errors.Is(err, resty.ErrRateLimitExceeded) // still true
errors.Is(err, context.DeadlineExceeded) // now also true
NOTE: this is a behaviour change for anyone comparing with
`err == resty.ErrRateLimitExceeded`; errors.Is is unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments