Skip to content

fix: remove INDEX_SPATIAL from DocumentsDB index creation#11679

Merged
abnegate merged 1 commit into1.9.xfrom
fix/remove-documentsdb-spatial
Mar 30, 2026
Merged

fix: remove INDEX_SPATIAL from DocumentsDB index creation#11679
abnegate merged 1 commit into1.9.xfrom
fix/remove-documentsdb-spatial

Conversation

@premtsd-code
Copy link
Copy Markdown
Contributor

Summary

Remove Database::INDEX_SPATIAL from the DocumentsDB index creation WhiteList. MongoDB's adapter silently fails on spatial indexes — the createCollection switch returns false in the default case for INDEX_SPATIAL, meaning the index never gets created but no error is thrown.

Changes

  • src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php — removed INDEX_SPATIAL from the type param WhiteList

Context

MongoDB adapter handles these index types:

  • INDEX_KEY — works (mapped to ascending/descending)
  • INDEX_FULLTEXT — works (mapped to MongoDB text index)
  • INDEX_UNIQUE — works
  • INDEX_SPATIAL — silently fails (falls through to default => return false)

Test plan

  • Create DocumentsDB collection → Indexes → verify Spatial is not in the type dropdown
  • Create Key, Fulltext, Unique indexes — verify they work
  • TablesDB/VectorsDB index creation unchanged

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

A whitelist validator for the type request parameter in the database indexes creation endpoint was modified to restrict allowed values. The change removed Database::INDEX_SPATIAL from the list of permitted index types, reducing the allowed values from four options to three: Database::INDEX_KEY, Database::INDEX_FULLTEXT, and Database::INDEX_UNIQUE. This is a single-line modification in the validation layer with no changes to control flow, other parameters, or response behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing INDEX_SPATIAL from DocumentsDB index creation, which is the primary modification in the changeset.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about why INDEX_SPATIAL was removed and the MongoDB adapter's silent failure behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-documentsdb-spatial

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR makes a focused, one-line fix that removes Database::INDEX_SPATIAL from the allowed index type whitelist for the DocumentsDB (MongoDB) Create endpoint. Because the MongoDB adapter's createIndex switch has no case for INDEX_SPATIAL and falls through to default => return false, accepting that type through the API would silently enqueue an index creation job that always produces no actual index without any user-visible error.

Key points:

  • The fix correctly prevents a user-facing silent-failure scenario: no error, no index.
  • TablesDB retains INDEX_SPATIAL in its whitelist, which is appropriate since that module targets SQL-backed adapters (MySQL/MariaDB) that do support spatial indexes.
  • The deprecated base class Databases/Collections/Indexes/Create.php also retains INDEX_SPATIAL; this is acceptable given it is deprecated since 1.8.0 and marked for replacement by tablesDB.createIndex.
  • No existing data is at risk — since MongoDB silently never created these indexes, there are no real spatial indexes to preserve or migrate.

Confidence Score: 5/5

Safe 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

Filename Overview
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php Removes INDEX_SPATIAL from the DocumentsDB type whitelist, preventing silent index creation failures against the MongoDB adapter.

Reviews (1): Last reviewed commit: "fix: remove INDEX_SPATIAL from Documents..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php (1)

61-61: Add a regression test for DocumentsDB INDEX_SPATIAL rejection.

Please add/adjust an API test to assert this endpoint now rejects type=spatial with 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d962e2 and c72d438.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Create.php

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit c72d438 - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.57s Logs
FunctionsScheduleTest::testCreateScheduledAtExecution 1 129.36s Logs

@github-actions
Copy link
Copy Markdown

✨ Benchmark results

  • Requests per second: 1,613
  • Requests with 200 status code: 290,458
  • P99 latency: 0.112083985

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,613 1,200
200 290,458 216,137
P99 0.112083985 0.191206748

@blacksmith-sh

This comment has been minimized.

@abnegate abnegate merged commit ea032c2 into 1.9.x Mar 30, 2026
80 of 81 checks passed
@abnegate abnegate deleted the fix/remove-documentsdb-spatial branch March 30, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants