Add int64 format support for integer attributes#11123
Conversation
📝 WalkthroughWalkthroughUpdates integer handling across the codebase: validator construction for integer min/max/default parameters changed from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧬 Code graph analysis (2)src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php (1)
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (2)
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 |
commit: |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
@src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php:
- Around line 60-62: The default parameter for integer columns uses Integer()
without 64-bit support while min/max use Integer(false, 64); update the default
param to use the same 64-bit integer type (i.e., replace Integer() with
Integer(false, 64) inside the Nullable wrapper) in all four endpoints so
validation is consistent — specifically fix the default param in TablesDB Tables
Columns Integer Update (Update.php), TablesDB Columns Integer Create
(Create.php), Databases Collections Attributes Integer Update (Update.php), and
Databases Collections Attributes Integer Create (Create.php) by changing the
Nullable(new Integer()) to Nullable(new Integer(false, 64)).
In @src/Appwrite/SDK/Specification/Format/OpenAPI3.php:
- Around line 627-629: The bug sets the integer format at the wrong schema level
for non-array WhiteList values: when $validator->getType() === 'integer' you
must assign the format to $node['schema']['format'] (not $node['format']) so the
OpenAPI output nests the format under the parameter schema; update the non-array
branch to mirror the array branch's approach (which uses
$node['schema']['items']['format']) and ensure $validator->getFormat() ??
'int32' is stored on $node['schema']['format'].
🧹 Nitpick comments (6)
src/Appwrite/Utopia/Response/Model/AttributeInteger.php (1)
26-48: Consider addingint64format to thedefaultrule for consistency.The
format: int64additions tominandmaxare correct. However, thedefaultrule (lines 42-48) still lacks this format specification. If a user setsminandmaxin the int64 range, they may also need to specify adefaultvalue in that range. Without the format, the API spec may incorrectly indicatedefaultis limited to int32.Suggested change
->addRule('default', [ 'type' => self::TYPE_INTEGER, + 'format' => 'int64', 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', 'default' => null, 'required' => false, 'example' => 10, ])src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php (1)
68-70: Inconsistent validation:defaultparameter lacks int64 support.The
minandmaxparameters now correctly support 64-bit integers. However,defaulton line 70 still usesnew Integer()without the 64-bit flag. This creates an inconsistency where users can set min/max values exceeding int32 range but cannot set adefaultvalue in that same range.Suggested fix
->param('min', null, new Nullable(new Integer(false, 64)), 'Minimum value', true) ->param('max', null, new Nullable(new Integer(false, 64)), 'Maximum value', true) - ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when attribute is required.') + ->param('default', null, new Nullable(new Integer(false, 64)), 'Default value. Cannot be set when attribute is required.')src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php (1)
58-60: Same inconsistency:defaultparameter should also support int64.For consistency with
minandmax, thedefaultparameter on line 60 should useInteger(false, 64)as well.Suggested fix
->param('min', null, new Nullable(new Integer(false, 64)), 'Minimum value', true) ->param('max', null, new Nullable(new Integer(false, 64)), 'Maximum value', true) - ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new Integer(false, 64)), 'Default value. Cannot be set when column is required.', true)src/Appwrite/Utopia/Response/Model/ColumnInteger.php (1)
26-48: Consider addingint64format to thedefaultrule for consistency.Similar to
AttributeInteger, thedefaultrule (lines 42-48) should include'format' => 'int64'to matchminandmax, ensuring API spec consistency for values in the int64 range.Suggested change
->addRule('default', [ 'type' => self::TYPE_INTEGER, + 'format' => 'int64', 'description' => 'Default value for column when not provided. Cannot be set when column is required.', 'default' => null, 'required' => false, 'example' => 10, ])src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php (1)
70-72: Inconsistent validation:defaultparameter should support int64.The
minandmaxparameters correctly support 64-bit integers, butdefaulton line 72 usesnew Integer()without the 64-bit flag. This prevents users from setting default values in the int64 range when their min/max constraints require it.Suggested fix
->param('min', null, new Nullable(new Integer(false, 64)), 'Minimum value', true) ->param('max', null, new Nullable(new Integer(false, 64)), 'Maximum value', true) - ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new Integer(false, 64)), 'Default value. Cannot be set when attribute is required.', true)src/Appwrite/SDK/Specification/Format/OpenAPI3.php (1)
551-557: Missing null fallback forgetFormat()call.Same issue as in
Swagger2.php— line 553 calls$validator->getFormat()without a fallback, while other locations in this file (line 603, 802) use fallbacks. Consider adding one for consistency:♻️ Proposed fix
case 'Utopia\Validator\Integer': $node['schema']['type'] = $validator->getType(); - $node['schema']['format'] = $validator->getFormat(); + $node['schema']['format'] = $validator->getFormat() ?? 'int32'; if (!empty($param['example'])) { $node['schema']['x-example'] = $param['example']; } break;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (13)
app/config/specs/open-api3-1.8.x-client.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-1.8.x-console.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-1.8.x-server.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-client.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-console.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-server.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-client.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-console.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-server.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-client.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-console.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-server.jsonis excluded by!app/config/specs/**composer.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.phpsrc/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.phpsrc/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.phpsrc/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.phpsrc/Appwrite/SDK/Specification/Format/OpenAPI3.phpsrc/Appwrite/SDK/Specification/Format/Swagger2.phpsrc/Appwrite/Utopia/Response/Model/AttributeInteger.phpsrc/Appwrite/Utopia/Response/Model/ColumnInteger.php
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-19T09:20:03.312Z
Learnt from: ItzNotABug
Repo: appwrite/appwrite PR: 9693
File: src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Update.php:57-59
Timestamp: 2025-06-19T09:20:03.312Z
Learning: In table-related endpoints (such as `src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Update.php`), parameter descriptions should use "table" and "row" terminology instead of "collection" and "document" for clarity and consistency.
Applied to files:
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php
🧬 Code graph analysis (5)
src/Appwrite/Utopia/Response/Model/ColumnInteger.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php (1)
src/Appwrite/GraphQL/Types/Mapper.php (1)
param(255-363)
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php (1)
src/Appwrite/GraphQL/Types/Mapper.php (1)
param(255-363)
src/Appwrite/Utopia/Response/Model/AttributeInteger.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php (1)
src/Appwrite/GraphQL/Types/Mapper.php (1)
param(255-363)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build SDK
- GitHub Check: scan
🔇 Additional comments (6)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php (1)
84-96: LGTM!The action logic correctly:
- Defaults
min/maxtoPHP_INT_MIN/PHP_INT_MAXfor full 64-bit range- Validates that
min <= max- Determines storage size (8 bytes for int64, 4 bytes for int32) based on the
maxthresholdsrc/Appwrite/SDK/Specification/Format/Swagger2.php (3)
686-688: LGTM!Good addition to propagate the
formatfield to body schema properties. This ensures integer parameters in request bodies correctly reflect their format (int32/int64) in the generated Swagger spec.
781-784: LGTM!The fallback to
'int32'ensures backward compatibility for model definitions that don't explicitly specify a format.
540-546: Review comment is incorrect—getFormat()always returns a non-null string.The
Utopia\Validator\Integer::getFormat()method has an explicit:stringreturn type (line 138) and always returns a concatenated string like'int32','uint8', etc., based on the bit size and signedness configuration. There is no code path where it could return null.The comparison to line 783 is not applicable—that line handles user-supplied rule format keys, not validator method returns. Additionally,
OpenAPI3.phpuses the same pattern without a fallback (calling$validator->getFormat()directly), confirming this is the intended design.The suggested fallback is unnecessary.
src/Appwrite/SDK/Specification/Format/OpenAPI3.php (2)
697-700: LGTM!Good addition to propagate the
formatfield to request body schema properties, ensuring integer parameters correctly reflect their format in the generated OpenAPI 3 spec.
800-803: LGTM!The fallback to
'int32'ensures backward compatibility for model schema definitions that don't explicitly specify a format.
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This pull request adds format: int64 specification to integer attribute min/max values to properly support large integer values that exceed the int32 range (2,147,483,647). This ensures that client SDKs correctly handle 64-bit integers when working with attribute constraints.
Changes:
- Modified
AttributeIntegerandColumnIntegerresponse models to includeformat: int64for min/max fields - Updated OpenAPI 3.x and Swagger 2.x specification generators to dynamically use validator format instead of hardcoding int32
- Updated endpoint parameter validators to use 64-bit Integer validator for min/max parameters
- Regenerated all API specification files (OpenAPI 3.x and Swagger 2.x for client, console, and server)
- Updated dependencies in composer.lock
Reviewed changes
Copilot reviewed 12 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| AttributeInteger.php | Added format: int64 to min/max field definitions in API response model |
| ColumnInteger.php | Added format: int64 to min/max field definitions in API response model |
| Swagger2.php | Modified to dynamically get format from validator instead of hardcoding int32 |
| OpenAPI3.php | Modified to dynamically get format from validator instead of hardcoding int32 |
| Create.php (4 files) | Updated Integer validator instantiation with 64-bit support for min/max parameters |
| Update.php (2 files) | Updated Integer validator instantiation with 64-bit support for min/max parameters |
| composer.lock | Updated multiple utopia-php dependencies |
| swagger2-*.json | Regenerated specification files with int64 format changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✨ Benchmark results
⚡ Benchmark Comparison
|
This change adds int64 format specification to integer attribute min/max values in the API response models and updates all OpenAPI/Swagger specifications accordingly. This ensures proper type handling for large integer values that exceed int32 range in client SDKs. Changes: - Add 'format: int64' to min/max fields in AttributeInteger and ColumnInteger models - Regenerate OpenAPI 3.x and Swagger 2.x specs for all platforms (client, console, server) - Update composer dependencies
d247ba2 to
ae6df78
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Appwrite/Utopia/Response/Model/ColumnInteger.php (1)
42-48: Missing'format' => 'int64'for thedefaultfield.The
minandmaxfields have been updated to include'format' => 'int64', but thedefaultfield (alsoTYPE_INTEGER) lacks this format specification. Since a default value must fall within the[min, max]range, it should also support int64 values.Proposed fix
->addRule('default', [ 'type' => self::TYPE_INTEGER, + 'format' => 'int64', 'description' => 'Default value for column when not provided. Cannot be set when column is required.', 'default' => null, 'required' => false, 'example' => 10, ])
🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php (1)
96-100: Pre-existing:intval()may truncate on 32-bit PHP.While not introduced by this PR, note that
intval()on lines 98-99 could truncate int64 values if running on 32-bit PHP. On 64-bit PHP (typical for modern deployments), this is not an issue. Consider using explicit casting(int)or documenting the 64-bit PHP requirement if int64 support is critical.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (13)
app/config/specs/open-api3-1.8.x-client.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-1.8.x-console.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-1.8.x-server.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-client.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-console.jsonis excluded by!app/config/specs/**app/config/specs/open-api3-latest-server.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-client.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-console.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-1.8.x-server.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-client.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-console.jsonis excluded by!app/config/specs/**app/config/specs/swagger2-latest-server.jsonis excluded by!app/config/specs/**composer.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.phpsrc/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.phpsrc/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.phpsrc/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.phpsrc/Appwrite/SDK/Specification/Format/OpenAPI3.phpsrc/Appwrite/SDK/Specification/Format/Swagger2.phpsrc/Appwrite/Utopia/Response/Model/AttributeInteger.phpsrc/Appwrite/Utopia/Response/Model/ColumnInteger.php
🚧 Files skipped from review as they are similar to previous changes (4)
- src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php
- src/Appwrite/Utopia/Response/Model/AttributeInteger.php
- src/Appwrite/SDK/Specification/Format/Swagger2.php
- src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php
🧰 Additional context used
🧬 Code graph analysis (3)
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php (1)
src/Appwrite/GraphQL/Types/Mapper.php (1)
param(255-363)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php (1)
src/Appwrite/GraphQL/Types/Mapper.php (1)
param(255-363)
src/Appwrite/Utopia/Response/Model/ColumnInteger.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
- GitHub Check: E2E Service Test (Console)
- GitHub Check: E2E Service Test (FunctionsSchedule)
- GitHub Check: E2E Service Test (GraphQL)
- GitHub Check: E2E Service Test (Realtime)
- GitHub Check: E2E Service Test (Sites)
- GitHub Check: E2E Service Test (Teams)
- GitHub Check: E2E Service Test (Account)
- GitHub Check: E2E Service Test (Functions)
- GitHub Check: E2E Service Test (Messaging)
- GitHub Check: E2E Service Test (Health)
- GitHub Check: E2E Service Test (Avatars)
- GitHub Check: E2E Service Test (Proxy)
- GitHub Check: E2E Service Test (Users)
- GitHub Check: E2E Service Test (Tokens)
- GitHub Check: E2E Service Test (Abuse enabled)
- GitHub Check: E2E Service Test (Site Screenshots)
- GitHub Check: Setup & Build SDK
- GitHub Check: scan
🔇 Additional comments (8)
src/Appwrite/Utopia/Response/Model/ColumnInteger.php (1)
26-41: LGTM for min/max format additions.Adding
'format' => 'int64'to theminandmaxrules correctly enables these fields to support values exceeding the int32 range (>2,147,483,647) in the OpenAPI specification output.src/Appwrite/SDK/Specification/Format/OpenAPI3.php (5)
697-700: LGTM for format propagation to request body.This correctly ensures that format metadata (e.g.,
int64) is carried over from parameter schemas to request body properties, maintaining consistency in the generated OpenAPI specification.
602-604: LGTM for WhiteList array integer format handling.The fallback to
'int32'ensures backward compatibility when the validator doesn't specify a format.
627-629: LGTM for WhiteList integer format handling.Consistent with the array case above, properly falls back to
'int32'.
800-803: LGTM for model integer rule format handling.Correctly uses
$rule['format'] ?? 'int32'to derive format from model rules (e.g., the'format' => 'int64'added to ColumnInteger and AttributeInteger models).
551-557: Consider adding a fallback forgetFormat()on the Integer validator.Other integer format assignments in this file (lines 603, 628, 802) use
?? 'int32'as a fallback, but this case does not. If$validator->getFormat()can returnnull, the schema will have anullformat rather than a sensible default. Consider applying the same fallback pattern for consistency.src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php (1)
68-70: LGTM for 64-bit integer validator updates.The validators for
min,max, anddefaultare correctly updated toNullable(Integer(false, 64)), matching the TablesDB counterpart and enabling int64 support.src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php (1)
60-62: LGTM for 64-bit integer validator updates.The validators for
min,max, anddefaultare correctly updated toNullable(Integer(false, 64))across both Create and Update endpoints, enabling support for values exceeding the int32 range. This is consistent with the PR objective and maintains consistency between the two endpoints.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 21 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
format: int64specification to integer attribute min/max values in API response modelsChanges
AttributeIntegermodel to includeformat: int64for min/max fields (src/Appwrite/Utopia/Response/Model/AttributeInteger.php:28, src/Appwrite/Utopia/Response/Model/AttributeInteger.php:36)ColumnIntegermodel to includeformat: int64for min/max fieldsTest plan