fix: remove INDEX_SPATIAL from DocumentsDB index creation#11679
fix: remove INDEX_SPATIAL from DocumentsDB index creation#11679
Conversation
📝 WalkthroughWalkthroughA whitelist validator for the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 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📝 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 SummaryThis PR makes a focused, one-line fix that removes Key points:
Confidence Score: 5/5Safe to merge — single-line whitelist fix that eliminates a silent failure with no side-effects on existing data or other adapters. The change is minimal, targeted, and correct. It prevents users from submitting spatial index requests to a MongoDB-backed adapter that silently discards them. No regressions are possible: TablesDB and the deprecated base-class endpoint are untouched, and there are no real spatial indexes in existing MongoDB collections to worry about. All remaining observations are at most P2 style notes, warranting a full 5/5. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: remove INDEX_SPATIAL from Documents..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php (1)
61-61: Add a regression test for DocumentsDBINDEX_SPATIALrejection.Please add/adjust an API test to assert this endpoint now rejects
type=spatialwith a clear validation error, so this behavior stays locked and intentional.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php` at line 61, Add a regression API test that posts to the DocumentsDB Collections Indexes Create endpoint (the codepath validated by the WhiteList in Create.php for the 'type' param) submitting type=spatial and assert the request is rejected with a validation error; implement a test (e.g., testCreateIndexRejectsSpatialType) that calls the same controller/route used by Create.php, sends type='spatial', expects a 4xx response (validation error) and asserts the response body contains a clear validation message indicating 'type' is invalid or not allowed (matching the project's validation error format).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php`:
- Line 61: Add a regression API test that posts to the DocumentsDB Collections
Indexes Create endpoint (the codepath validated by the WhiteList in Create.php
for the 'type' param) submitting type=spatial and assert the request is rejected
with a validation error; implement a test (e.g.,
testCreateIndexRejectsSpatialType) that calls the same controller/route used by
Create.php, sends type='spatial', expects a 4xx response (validation error) and
asserts the response body contains a clear validation message indicating 'type'
is invalid or not allowed (matching the project's validation error format).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ecb75ff7-8b23-40fe-9184-6395e0ad6395
📒 Files selected for processing (1)
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php
✨ Benchmark results
⚡ Benchmark Comparison
|
Summary
Remove
Database::INDEX_SPATIALfrom the DocumentsDB index creation WhiteList. MongoDB's adapter silently fails on spatial indexes — thecreateCollectionswitch returnsfalsein the default case forINDEX_SPATIAL, meaning the index never gets created but no error is thrown.Changes
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php— removedINDEX_SPATIALfrom the type param WhiteListContext
MongoDB adapter handles these index types:
INDEX_KEY— works (mapped to ascending/descending)INDEX_FULLTEXT— works (mapped to MongoDBtextindex)INDEX_UNIQUE— worksINDEX_SPATIAL— silently fails (falls through todefault => return false)Test plan