fix(mongo): bump to 1.5.3 so integers past int32 survive a read - #936
Conversation
Two paths lost or corrupted integer values outside the int32 range on
Mongo, because the driver decodes 64-bit BSON integers as Int64 wrappers
and neither path casts them.
sum() returns the aggregate total straight off the cursor and declares
float|int, so any total past int32 was a return type violation:
TypeError: Mongo::sum(): Return value must be of type int|float,
MongoDB\BSON\Int64 returned
Object attributes have no per-key schema, so castingAfter() has nothing
to cast against and the wrapper reached the response, serialising as
{"$numberLong":"-3408048000"} instead of a number.
Both tests live in shared scopes and pass on Mongo, Postgres, MySQL,
MariaDB, SQLite and Memory. They need utopia-php/mongo 1.5.3
(utopia-php/mongo#49), which normalises at the decode boundary.
Refs appwrite/appwrite#13175
1.5.3 normalises BSON int64 to native PHP integers at the decode boundary (utopia-php/mongo#49), which is what the two tests in the preceding commit need to pass on Mongo.
|
Warning Review limit reached
Next review available in: 53 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request adds end-to-end tests for signed 64-bit integer preservation in documents and object attributes. The tests cover retrieval, queries, aggregation, cache invalidation, native integer types, exact values, and plain JSON serialization. Changes64-bit integer preservation
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This localized dependency update fixes large-integer decoding and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThe PR updates
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(test): satisfy level 7 on the json_e..." | Re-trigger Greptile |
json_encode() is string|false, which assertStringNotContainsString() will not take. JSON_THROW_ON_ERROR narrows it to string and turns a silent false into an exception, which is what we want in a test anyway.
Carries the int64 regression tests from utopia-php/database#936, and the unique violation classification work from #733, which now keys off the violated constraint instead of matching on the driver message.
Closes the utopia-php/database half of appwrite/appwrite#13175 — BigInt[] Breaks MongoDb.
What was broken
MongoDB\BSON\Document::toPHP()decodes every 64-bit BSON integer as aMongoDB\BSON\Int64wrapper on all platforms, so anything outside the int32 range came back from Mongo as an object. utopia-php/mongo#49 fixes that at the decode boundary; this bumps the lock to 1.5.3 and adds the two regression tests that hold it in place.Only
utopia-php/mongomoves in the lock, 1.5.2 → 1.5.3.Why the tests target these two paths
Typed
integer/bigintattributes were already fine onmain:castingAfter()applies(int)$node, and ext-mongodb 2.x givesInt64a numeric cast handler, so that returns the right value. The two paths with no cast to lean on were the real leaks:sum()returns the aggregate total straight off the cursor and declaresfloat|int, so any total past int32 was a hard return type violation:Two rows of
2000000000is enough to trip it.Object attributes have no per-key schema, so
castingAfter()has nothing to cast against. The wrapper reached the response and serialised as{"count":{"$numberLong":"-3408048000"}}instead of a number — wrong data on the wire, no error anywhere.Both are in shared scopes rather than
MongoDBTest, because the assertion (native PHP integers, no$numberLongin the JSON) is a contract every adapter should meet, not Mongo trivia.Verification
MongoDBTestagainst the real released 1.5.3: 663 tests, 4997 assertions, 0 failures, 5 pre-existing skips.pint --testpasses on both changed files.Note for anyone reproducing locally: a stale
vendorin the test image shows up as twotestObjectAttribute*EmptyObject*failures ({}vs[]). That isutopia-php/cache4.0.1 against a lock that wants 4.0.2, not this change. Rebuilding the image clears it.Not verified
assertEqualsplus a$numberLongsubstring check rather than an exact JSON string, because Postgresjsonbdoes not preserve key order. So the test pins types and values, not serialised layout.Summary by CodeRabbit