Skip to content

Add KEYVIZ_KEY_BUCKETS_PER_ROUTE validation#844

Open
bootjp wants to merge 1 commit into
mainfrom
add-keyviz-validation
Open

Add KEYVIZ_KEY_BUCKETS_PER_ROUTE validation#844
bootjp wants to merge 1 commit into
mainfrom
add-keyviz-validation

Conversation

@bootjp
Copy link
Copy Markdown
Owner

@bootjp bootjp commented May 26, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@bootjp, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70337478-5aa3-4402-a9ca-ffa5c96fe773

📥 Commits

Reviewing files that changed from the base of the PR and between 312393e and 0f1a0f4.

📒 Files selected for processing (1)
  • scripts/rolling-update.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-keyviz-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the KEYVIZ_KEY_BUCKETS_PER_ROUTE configuration to scripts/rolling-update.sh to support sub-range buckets per route in KeyViz. Feedback suggests improving the validation logic for this variable by restricting it to a range of 1 to 256 via a precise regular expression, preventing potential integer overflow or silent clamping issues.

Comment thread scripts/rolling-update.sh
Comment on lines +277 to +280
if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^[1-9][0-9]*$ ]]; then
echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or a positive integer, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2
exit 1
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current validation checks if KEYVIZ_KEY_BUCKETS_PER_ROUTE is a positive integer, but it does not enforce the maximum limit of 256 (defined as MaxKeyBucketsPerRoute in keyviz/sampler.go).

If an operator configures a value larger than 256, it will be silently clamped by the Go binary. More importantly, if they enter an extremely large number that overflows a standard integer, the Go flag parser will fail to parse it, leading to a container crash-loop. This defeats the purpose of pre-validating the flag in this script.

We can use a precise regular expression to restrict the value to the valid range of 1 to 256 inclusive, which is also completely immune to integer overflow.

Suggested change
if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^[1-9][0-9]*$ ]]; then
echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or a positive integer, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2
exit 1
fi
if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^([1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-6])$ ]]; then
echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or an integer between 1 and 256, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2
exit 1
fi

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.

1 participant