Repository navigation
fix(validators): state the exact 64-bit bounds in the Integer description - #14584
Conversation
…tion Integer computed its bounds with **, which returns a float once the result passes PHP_INT_MAX, so (2 ** 63) - 1 became 9.2233720368547758E18 and the description printed the signed 64-bit maximum as 9,223,372,036,854,775,808. The bounds are now integers shifted from PHP_INT_MAX, so the description reads 9,223,372,036,854,775,807 and validation compares ints with ints. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR fixes a precision bug in
Reviewed commit: 44c2e86 |
🟢 Tier S · Ready to merge
The Integer validator now derives validation bounds and descriptions from the same integer limits, correcting the signed 64-bit maximum. The PR adds unit and end-to-end regressions for exact range messages and inclusive 64-bit boundaries, and records the fix in the validators changelog. Latest changes: The newest commit rejects integer widths that cannot fit the current PHP build and simplifies the maximum calculation based on that constraint.
📂 Walkthrough · 4
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The shifts assumed 64-bit PHP integers. On 32-bit PHP a signed 8-bit validator would compute a maximum of 0; the bounds now shift from the native width and clamp a width PHP cannot represent to PHP_INT_MAX. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clamping a width wider than the native integers to PHP_INT_MAX made a uint32 validator on 32-bit PHP describe its maximum as 2,147,483,647. A width that does not fit is now refused at construction, as 64-bit unsigned already was, so every validator that exists states its exact bounds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
Staging QA: a bigint column bound out of range answered "…between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,808". The real int64 maximum is …807.
Why
packages/validators/src/Integer.php(utopia-php/validators, absorbed into this monorepo) computed its bounds as(2 ** ($bits - 1)) - 1.**returns a float once the result passesPHP_INT_MAX, so the 64-bit maximum became9.2233720368547758E18, andnumber_format()rounded it to …808.Fix
getMin()/getMax()compute integer bounds:PHP_INT_MAX >> (64 - $bits)for signed and(1 << $bits) - 1for unsigned (64-bit unsigned is already refused).getDescription()andisValid()both use them, so validation now compares ints with ints. Added a CHANGELOG entry under Unreleased.Tests
origin/mainpackages/validators/tests/IntegerTest::testDescriptionStatesTheExactBounds(int64, int32, uint32, int8)…854,775,808…854,775,807IntegerTest::testSixtyFourBitBoundsAreInclusive(PHP_INT_MAX/MIN, loose strings one past each bound)TablesDBColumnsTest::testBigIntColumnBoundOutOfRangeStatesTheInt64Range(POST …/columns/bigintwithmax: 1e19)…775,808 or null…775,807 or nullbin/monorepo check validatorspasses, and the fullTablesDBColumnsTestpasses locally.🤖 Generated with Claude Code