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
Large integer Retry-After values can overflow when converted from seconds to time.Duration. A positive delay can become zero, while a malformed negative value can become a large positive wait.
Parse seconds with an explicit 64-bit width, reject negatives before multiplication, and saturate valid positive delays at the maximum representable duration. Validate the entire decimal value after a parsing overflow so malformed suffixes still fall back to zero. Ordinary integer and HTTP-date behavior is preserved.
This addresses the representational overflow discussed in #5389; the bound is time.Duration's limit rather than a retry-policy cutoff.
I have already tried to use the Webhook Receiver Integration and third-party integrations before adding this new Receiver Integration
Is this a bugfix? Yes.
I have added tests that reproduce the bug and pass with this fix
Is this a new feature? No.
I have added tests that test the new feature's functionality
Does this change affect performance? No intended performance change.
I have provided benchmarks comparison
I have added new benchmarks if required or requested
Is this a breaking change? No.
My changes do not break existing cluster messages
My changes do not break the existing API
The exported helper's documentation describes saturation
I have signed-off my commits
I will follow best practices for contributing to this project
Validation:
Seven boundary regressions fail against the unchanged helper. The fixed parser passes all 23 table cases, including malformed oversized integers and HTTP dates.
All notifier packages pass on Go 1.26.5; race checks pass for the shared notifier package, Slack and Webex.
Independent arbitrary-precision/date and lexical-reference harnesses pass 24,210 and 234,972 cases respectively, including threshold neighbors, malformed byte sequences and very long inputs.
The actual notifier tests cross-compile for linux/386 on Go 1.26.5; 386 execution was not performed.
make common-format and make lint pass with pinned golangci-lint v2.14.0; Elm/Mantine builds, all 43 UI tests and UI lint pass.
Full Linux go test ./... with built assets and versioned server/CLI binaries has one failure, TestAlertGetReturnsCurrentAlertStatus. The exact unchanged baseline 373edcb5a2dbdf6a6f7c08de3078cf19f996b47d reproduces that same failure. All other packages pass.
Which user-facing changes does this PR introduce?
[BUGFIX] Notifications: Prevent large Retry-After values from wrapping into incorrect retry delays.
Reviewing files that changed from the base of the PR and between f67035f and 0b5b5ed.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
ParseRetryAfter now parses integer delays as signed 64-bit seconds, returns zero for negative values, and caps delays above the time.Duration limit. Tests add coverage for large values and malformed overflow inputs.
ParseRetryAfter uses 64-bit integer parsing, returns zero for negative values, and caps oversized delays at the duration maximum. Tests cover values beyond 32-bit and integer limits, plus overflow strings with trailing text.
This change prevents very large Retry-After values from wrapping into incorrect retry delays. Ordinary integer and HTTP-date handling is intended to stay the same, and tests cover the boundary cases. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "notify: prevent Retry-After duration overflow" names the main change: the fix for integer Retry-After values that overflow when converted to time.Duration. It follows the area: description …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description explains the overflow problem in ParseRetryAfter, the fix (64-bit parsing, rejecting negatives before multiplication, saturating positive delays, validating the full decimal value afte…
Full details: Title check
Explanation
The title "notify: prevent Retry-After duration overflow" names the main change: the fix for integer Retry-After values that overflow when converted to time.Duration. It follows the area: description form the template asks for and matches the raw summary, the PR objectives, and the release note.
Full details: Description check
Explanation
The description explains the overflow problem in ParseRetryAfter, the fix (64-bit parsing, rejecting negatives before multiplication, saturating positive delays, validating the full decimal value after overflow), and the reference to #5389. It fills in most checklist items and includes a release-notes block. The template's title format and the 'Fixes #' line are not addressed. The 'Which user-facing changes' section is complete. The checklist leaves the performance benchmark item unchecked, which is acceptable because the author states there is no intended performance change. The description is mostly complete.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 373edcb and f67035f.
Files selected for processing: 2
notify/util.go
notify/util_test.go
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Read against main, and I ran strconv.ParseInt on the overflow inputs. The fix is right, and the digit loop is needed, for the reason the comment gives:
"+18446744073709551616x" (past uint64) returns ErrRange with MaxInt64 before ParseUint reaches the x, so without the loop it would saturate instead of falling back to 0.
"9223372036854775808seconds" (past int64 but within uint64) comes back as invalid syntax first, so that test case passes through the HTTP-date fallback, not the loop. It's worth knowing if someone later trims the loop as unused for that case.
The saturation boundary checks out: 9223372036 * 1e9 fits in an int64 and 9223372037 * 1e9 doesn't. Both callers (Slack and Webex) pass the result straight to notify.Retry, so the cap on how long a retry may wait stays the question for #5389, as the description says.
One small thing to decide rather than fix: ParseInt accepts a leading +, as Atoi did, so +5 is still 5 s, although RFC 9110's 1*DIGIT makes it malformed like the negative case. Keeping it avoids a behaviour change.
Read and the parse cases run; I didn't run the package tests.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I don't see the value there. If the server is reporting 292 years of backoff, something is broken already. There is no value in detecting this case (It will really be clamped to the normal backoff). It already was an AI comment back then, which we rejected. Reopening such a PR is questionable.
Sorry, but I don't see the value there. If the server is reporting 292 years of backoff, something is broken already. There is no value in detecting this case (It will really be clamped to the normal backoff). It already was an AI comment back then, which we rejected. Reopening such a PR is questionable.
@SoloJacobs - Thanks for clarifying and pointing me back to the earlier discussion. One question before I close this: max(backoff, retryAfter) handles nonpositive overflow results, but a wrapped positive value can still extend the wait. Would a smaller change that treats unrepresentable values as invalid and falls back to ordinary backoff be useful, or would you prefer to leave these extreme inputs out of scope?
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
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.
Large integer
Retry-Aftervalues can overflow when converted from seconds totime.Duration. A positive delay can become zero, while a malformed negative value can become a large positive wait.Parse seconds with an explicit 64-bit width, reject negatives before multiplication, and saturate valid positive delays at the maximum representable duration. Validate the entire decimal value after a parsing overflow so malformed suffixes still fall back to zero. Ordinary integer and HTTP-date behavior is preserved.
This addresses the representational overflow discussed in #5389; the bound is
time.Duration's limit rather than a retry-policy cutoff.Pull Request Checklist
Validation:
make common-formatandmake lintpass with pinned golangci-lint v2.14.0; Elm/Mantine builds, all 43 UI tests and UI lint pass.go test ./...with built assets and versioned server/CLI binaries has one failure,TestAlertGetReturnsCurrentAlertStatus. The exact unchanged baseline373edcb5a2dbdf6a6f7c08de3078cf19f996b47dreproduces that same failure. All other packages pass.Which user-facing changes does this PR introduce?