Skip to content

Block array indexes#10917

Merged
abnegate merged 2 commits into1.8.xfrom
fix-array-index
Dec 8, 2025
Merged

Block array indexes#10917
abnegate merged 2 commits into1.8.xfrom
fix-array-index

Conversation

@abnegate
Copy link
Copy Markdown
Member

@abnegate abnegate commented Dec 8, 2025

What does this PR do?

Because of a bug in MySQL, we cannot create indexes on array attributes for now, otherwise queries break (by not returning any data). This PR temporarily disables creating indexes on arrays.

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 8, 2025

📝 Walkthrough

Walkthrough

Replaces prior array-attribute handling in Databases index creation: instead of assigning default length/order for array attributes, the code now throws an INDEX_INVALID exception with message "Creating indexes on array attributes is not currently supported." The change also removes generation of default system attributes (createdAt/updatedAt) in the oldAttributes metadata, reformats the attribute-metadata mapping, and updates tests to expect 400 responses and the new error message where index creation on array attributes is attempted. Minor formatting and comment cleanup included.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect Create.php changes for correct exception type/code (INDEX_INVALID) and exact message.
  • Verify removal of createdAt/updatedAt from oldAttributes metadata does not break other consumers.
  • Review tests in tests/e2e/Services/Databases/** for updated expectations (status codes, error messages, index counts).
  • Confirm no remaining code paths attempt to create indexes for array attributes or silently assume array handling.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is a template with no actual content provided, making it impossible to assess relatedness to the changeset. Replace the template with a substantive description of what the PR does, why it's needed, and how the changes were tested.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Block array indexes' directly and specifically describes the main change: preventing index creation on array attributes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-array-index

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 8, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
imagemagick 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-c++ 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-dev 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-heic 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jpeg 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jxl 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-libs 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-openexr 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-webp 7.1.2.3-r0 CVE-2025-62171 HIGH
libecpg 17.6-r0 CVE-2025-12818 HIGH
libecpg-dev 17.6-r0 CVE-2025-12818 HIGH
libpng 1.6.47-r0 CVE-2025-64720 HIGH
libpng 1.6.47-r0 CVE-2025-65018 HIGH
libpng-dev 1.6.47-r0 CVE-2025-64720 HIGH
libpng-dev 1.6.47-r0 CVE-2025-65018 HIGH
libpq 17.6-r0 CVE-2025-12818 HIGH
libpq-dev 17.6-r0 CVE-2025-12818 HIGH
libxml2 2.13.8-r0 CVE-2025-49794 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49796 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49795 HIGH
libxml2 2.13.8-r0 CVE-2025-6021 HIGH
postgresql17-dev 17.6-r0 CVE-2025-12818 HIGH
github.com/containerd/containerd/v2 v2.0.2 CVE-2024-25621 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH
stdlib 1.22.10 CVE-2025-58183 HIGH
stdlib 1.22.10 CVE-2025-58186 HIGH
stdlib 1.22.10 CVE-2025-58187 HIGH
stdlib 1.22.10 CVE-2025-61729 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 8, 2025

✨ Benchmark results

  • Requests per second: 1,179
  • Requests with 200 status code: 212,332
  • P99 latency: 0.163595878

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,179 1,233
200 212,332 221,966
P99 0.163595878 0.166341487

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.

Actionable comments posted: 0

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

171-173: Guarding against indexes on array attributes matches the intent; consider future‑proofing

The explicit guard on $attributeArray === true with Exception::INDEX_INVALID and a clear message is an appropriate way to block problematic array-attribute indexes and gives clients a precise failure reason. One optional improvement for later would be to gate this on adapter capabilities (or a feature flag) so that when the underlying MySQL issue is resolved or alternative adapters support array indexes, this behavior can be relaxed without touching endpoint logic again.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 425bd51 and aec7f27.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php (2 hunks)
  • tests/e2e/Services/Databases/Legacy/DatabasesBase.php (8 hunks)
  • tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (6 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: abnegate
Repo: appwrite/appwrite PR: 10800
File: tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php:5661-5662
Timestamp: 2025-11-12T08:56:08.516Z
Learning: The arrayInsert operator in Appwrite's database transactions uses the format: `{"method":"arrayInsert","attribute":"","values":[index, value]}` where the index is taken from values[0] and the actual value to insert is taken from values[1]. This differs from having separate "index" and "values" fields.
🧬 Code graph analysis (1)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php (1)
src/Appwrite/Extend/Exception.php (1)
  • Exception (7-465)
⏰ 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)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (3)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php (1)

111-114: Attribute metadata mapping is clear and consistent with later usage

Building $oldAttributes via array_map(fn ($a) => $a->getArrayCopy(), $collection->getAttribute('attributes')) cleanly normalizes the collection’s attribute documents into arrays and aligns with later array_column($oldAttributes, 'key') and direct array access. No issues from a correctness or readability standpoint here.

tests/e2e/Services/Databases/Legacy/DatabasesBase.php (2)

1354-1423: Array-attribute index blocking tests look correct and comprehensive

The updated assertions for fulltextArray, actorsArray, twoLevelsArray, index1 and index2 all consistently expect HTTP 400 and the unified message "Creating indexes on array attributes is not currently supported.", which aligns well with the new behavior and covers single, multi-attribute, and ordered index cases. The reduced index count assertion (4 indexes) also matches the remaining non-array index creations earlier in the test. I don’t see any functional gaps here.


1490-1503: New length+array index negative case is a good edge‑case addition

The extra branch in testGetIndexByKeyWithLengths that attempts a length override on the actors array attribute and asserts 400 plus the same “array attributes” error message cleanly exercises the new guard in the lengths path without affecting the existing positive lengths test. This nicely closes a potential hole in validation.

@abnegate abnegate merged commit 689e61c into 1.8.x Dec 8, 2025
41 checks passed
@abnegate abnegate deleted the fix-array-index branch December 8, 2025 10:51
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.

1 participant