Fix misleading QuotaConfig error messages and reject non-finite maxQueriesPerSecond - #19237
Fix misleading QuotaConfig error messages and reject non-finite maxQueriesPerSecond#19237dkranchii wants to merge 1 commit into
Conversation
…eriesPerSecond - Fix wrong-variable interpolation in the 'maxQueriesPerSecond' error path (previously reported the 'storage' input, e.g. "Invalid 'maxQueriesPerSecond': null"). - Preserve the underlying parse/validation exception as the cause on both 'storage' and 'maxQueriesPerSecond' throws so operators see the root cause. - Give Preconditions.checkArgument on '_maxQPS > 0' a descriptive message. - Tighten the positivity check to Double.isFinite && > 0 so 'Infinity' and 'NaN' inputs are rejected (previously 'Infinity' was silently accepted as an undocumented back-door for unlimited QPS). - Add regression tests covering the field name, offending value, cause chain, zero, non-finite inputs, and the Jackson deserialization path.
There was a problem hiding this comment.
Pull request overview
This pull request fixes QuotaConfig validation so operators get accurate, actionable errors when storage or maxQueriesPerSecond are invalid, and it closes a loophole where non-finite QPS values (Infinity/NaN) could bypass validation.
Changes:
- Fixes the
maxQueriesPerSecondvalidation error to interpolate the correct input value and to preserve the underlying exception as the cause. - Makes the QPS validation explicitly reject non-finite numbers (
Double.isFinite(...) && > 0) and provides a non-nullcheckArgumentmessage. - Adds focused unit tests covering message contents, cause chaining, zero/non-positive boundaries, non-finite inputs, and the Jackson deserialization path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pinot-spi/src/main/java/org/apache/pinot/spi/config/table/QuotaConfig.java |
Corrects error messages/cause propagation and rejects non-finite/invalid QPS inputs during config validation. |
pinot-spi/src/test/java/org/apache/pinot/spi/config/table/QuotaConfigTest.java |
Adds regression tests to ensure validation errors surface the right field/value and preserve exception causes (including JSON deserialization). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19237 +/- ##
=========================================
Coverage 66.94% 66.95%
Complexity 1423 1423
=========================================
Files 3452 3452
Lines 218564 218565 +1
Branches 34731 34731
=========================================
+ Hits 146320 146339 +19
+ Misses 60549 60536 -13
+ Partials 11695 11690 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
QuotaConfigproduces misleading validation errors when a table config has a badstorageormaxQueriesPerSecondvalue. Four defects fixed:maxQueriesPerSecond, the code threw"Invalid 'maxQueriesPerSecond': " + storage, so the operator saw thestoragevalue (ornull) instead of the offending QPS input.IllegalArgumentExceptionthrows dropped the underlyingNumberFormatException/ parse exception, so stack traces had no root cause.Preconditions.checkArgument.Preconditions.checkArgument(_maxQPS > 0)had no message; a non-positive QPS produced anIllegalArgumentExceptionwith anullmessage."Infinity"bypass.Double.parseDouble("Infinity")returnsPOSITIVE_INFINITY, which passes> 0— an undocumented back-door for unlimited QPS."NaN"was also silently reaching downstream code.Changes
pinot-spi/src/main/java/org/apache/pinot/spi/config/table/QuotaConfig.java(+4 / -3):maxQueriesPerSecond(notstorage) in the QPS error message.eon bothIllegalArgumentExceptionthrows.Preconditions.checkArgumenta descriptive message that includes the offending value.Double.isFinite(_maxQPS) && _maxQPS > 0soInfinity,-Infinity, andNaNare all rejected.pinot-spi/src/test/java/org/apache/pinot/spi/config/table/QuotaConfigTest.java(+109, tests only) — six new focused tests covering the field name, offending value, cause chain, zero boundary, non-finite inputs, and the Jackson deserialization path.Backward compatibility
"Invalid 'maxQueriesPerSecond': null"(the buggy pre-fix message) will need to update, but the corrected format is what the code clearly intended."Infinity"/"NaN"inputs now fail validation. If any deployment relied on"Infinity"as a shortcut for "unlimited", they should omit the field instead (which already means "unlimited" viaINVALID_MAX_QPS = -1.0).Note on overlap with #16016
PR #16016 (a much larger, ~1-year-old feature refactor: "Enable Ratelimiter Quota with Flexible Configuration") also modifies
QuotaConfig.javaandQuotaConfigTest.java. That PR is a feature refactor with orthogonal concerns; this PR is a focused bug fix on the existing validation error paths. Happy to rebase whichever merges second.Test plan
QuotaConfigTestcovering all four defects, plus boundary cases (0,Infinity,-Infinity,NaN) and the Jackson deserialization path../mvnw -pl pinot-spi -am -Dtest=QuotaConfigTest testplus spotless / checkstyle / license.