8000 Fix indexes for `1.7.x` by ItzNotABug · Pull Request #9752 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix indexes for 1.7.x #9752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2025
Merged

Fix indexes for 1.7.x #9752

merged 4 commits into from
May 13, 2025

Conversation

ItzNotABug
Copy link
Member
@ItzNotABug ItzNotABug commented May 13, 2025

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

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?

Summary by CodeRabbit

  • Refactor
    • Updated attributes used in data indexes to enhance information organization and access.
  • Bug Fixes
    • Removed obsolete search fields from deployment and duplication processes to streamline data handling.
  • Tests
    • Simplified and corrected test cases by removing search filters and standardizing assertions for deployments, projects, and sites.

Copy link
coderabbitai bot commented May 13, 2025

Walkthrough

The changes update index definitions in two configuration files. In the rules collection, the indexed attributes for a specific index are changed to reference deployment-related fields. In the executions collection, the indexed attribute for a particular index is updated to use a resource-related field instead of a function-related one. Additionally, multiple deployment-related document creations across function and site modules have the 'search' attribute removed. Corresponding test cases were adjusted to remove search filters and update parameter names for deployment creation.

Changes

File(s) Change Summary
app/config/collections/platform.php Modified the _key_piid_riid_rt index in the rules collection to use deploymentInternalId and deploymentResourceType instead of resourceInternalId and resourceType.
app/config/collections/projects.php Changed the _key_function_internal_id index in the executions collection to use resourceInternalId instead of functionInternalId.
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php Removed the 'search' attribute from the deployment document creation payload.
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php Removed the 'search' attribute from the deployment document creation payload.
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php Removed the 'search' attribute from deployment and rules document creation in the action method.
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php Removed the 'search' attribute from deployment and rules document creation arrays.
tests/e2e/Services/Functions/FunctionsCustomServerTest.php Changed deployment creation key from 'functionId' to 'resourceId'; removed search filter in deployment listing and simplified assertions.
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php Removed search filter from project dev keys listing; adjusted assertions to expect multiple keys without filtering.
tests/e2e/Services/Sites/SitesCustomServerTest.php Removed search filter from site listing; adjusted call to list all sites without filtering.

Poem

A hop and a skip, the indexes shift,
From function to resource, a subtle lift.
Deployments now tracked in the rules array,
Collections aligned in a clever way.
Search fields vanish, tests dance anew,
A rabbit’s delight in code so true! 🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d50b3f1 and 6ea10db.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php (0 hunks)
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php (0 hunks)
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php (0 hunks)
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php (0 hunks)
  • tests/e2e/Services/Functions/FunctionsCustomServerTest.php (2 hunks)
  • tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (1 hunks)
  • tests/e2e/Services/Sites/SitesCustomServerTest.php (1 hunks)
💤 Files with no reviewable changes (4)
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php
  • src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php
  • src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (1)
src/Appwrite/Utopia/Request.php (1)
  • getHeaders (162-184)
tests/e2e/Services/Sites/SitesCustomServerTest.php (1)
tests/e2e/Services/Sites/SitesBase.php (1)
  • listSites (191-199)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (Tokens)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V1)
  • GitHub Check: E2E Service Test (Dev Keys)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V2)
  • GitHub Check: Unit Test
  • GitHub Check: E2E General Test
  • GitHub Check: scan
🔇 Additional comments (5)
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php (1)

4454-4462: Removal of search filter in dev keys test aligns with API changes.

The test has been updated to remove the search parameter when listing dev keys, now expecting to retrieve all dev keys instead of filtering for only those containing "Dev". This matches the broader pattern of search attribute removal mentioned in the summary.

tests/e2e/Services/Sites/SitesCustomServerTest.php (1)

641-641: LGTM: Updated to retrieve all sites without filtering.

The search parameter has been removed from the listSites() call, which aligns with the broader changes to indexes mentioned in the PR summary. This change maintains the test's core functionality while reflecting the updated indexing approach.

tests/e2e/Services/Functions/FunctionsCustomServerTest.php (3)

399-399: Change of identifier parameter: functionIdresourceId

This change aligns with the updated indexing conventions where resource identification has been standardized to use resourceId instead of function-specific identifiers, improving consistency across the platform.


731-731: Standardized assertion syntax

The assertion calls have been standardized to have the expected value as the first parameter and the actual value as the second parameter, improving code consistency and readability.

Also applies to: 738-738


734-734: Removed search parameter from deployment listing

The search parameter has been removed from the listDeployments call, consistent with backend updates that remove the 'search' field from deployment documents. The corresponding assertions that depended on the filtered results have also been simplified to only verify the status code and that the deployments array is valid.

Also applies to: 737-737

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ItzNotABug ItzNotABug self-assigned this May 13, 2025
Copy link
@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: 1

🧹 Nitpick comments (1)
app/config/collections/projects.php (1)

2086-2089: Consider updating the index name to match the new attribute name

While the attribute has been updated, the index name _key_function_internal_id still references the old attribute name, which could lead to confusion during future maintenance.

Consider updating the index name to better reflect its current purpose:

- '$id' => ID::custom('_key_function_internal_id'),
+ '$id' => ID::custom('_key_resource_internal_id'),
  'type' => Database::INDEX_KEY,
  'attributes' => ['resourceInternalId'],
  'lengths' => [],
  'orders' => [],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33d4650 and d50b3f1.

📒 Files selected for processing (2)
  • app/config/collections/platform.php (1 hunks)
  • app/config/collections/projects.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (1)
app/config/collections/projects.php (1)

2086-2086:

✅ Verification successful

Index attribute renamed for standardization

The attribute for the _key_function_internal_id index has been updated from functionInternalId to resourceInternalId, establishing consistent naming patterns across the codebase for resource references.

Let's verify that there are no references to the old attribute name that might be affected by this change:


🏁 Script executed:

#!/bin/bash
# Search for any code referencing the old attribute name
rg "functionInternalId" --type php

Length of output: 2462


Confirming rename of functionInternalIdresourceInternalId

Search for “functionInternalId” returns only migration scripts (V15, V17, V19, V20) where the attribute is created and then renamed in V19. All application code (queries, deletes, etc.) already uses resourceInternalId. No remaining references to update—ready to approve.

@@ -1420,7 +1420,7 @@
[
'$id' => ID::custom('_key_piid_riid_rt'),
'type' => Database::INDEX_KEY,
'attributes' => ['projectInternalId', 'resourceInternalId', 'resourceType'],
'attributes' => ['projectInternalId', 'deploymentInternalId', 'deploymentResourceType'],
Copy link
@coderabbitai coderabbitai bot May 13, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Index attributes updated to align with deployment terminology

The attributes for the _key_piid_riid_rt index have been updated from resource-based to deployment-based identifiers, which aligns with modern deployment-focused architecture.

Let's verify that this change has been consistently applied across the codebase:


🏁 Script executed:

#!/bin/bash
# Search for any code that might be using the old index attributes
rg "resourceInternalId.*resourceType" --type php

Length of output: 5420


Inconsistent index definitions: update remaining resource-based indexes

I see the _key_piid_riid_rt index in app/config/collections/platform.php has been updated to use deploymentInternalId and deploymentResourceType, but there are still other index definitions that reference the old resourceInternalId/resourceType fields. Please update these to match the new deployment-based naming:

  • app/config/collections/platform.php
    • Index on ['projectInternalId', 'resourceInternalId', 'resourceType']
  • app/config/collections/projects.php
    • Multiple indexes with ['resourceInternalId', 'resourceType']
    _key_resourceInternalId_resourceType

Once these are updated, all platform- and project-collection indexes will consistently use deploymentInternalId and deploymentResourceType.

Copy link
Member Author

Choose a reason for hiding this comment

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

those work fine because they have the same attributes. the docker build on local went fine and the stack started fine as well without any errors.

Copy link

Choose a reason for hiding this comment

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

@ItzNotABug Thanks for the clarification. I understand that both naming patterns are functionally equivalent and your local testing confirms everything works properly. While standardizing the naming across all indexes could help with code readability and maintenance in the future, it's not causing any functional issues.

Would you like me to stop flagging these naming inconsistencies in this PR since your primary goal is to fix specific indexes for version 1.7.x rather than standardizing all names?

(_/)
( •_•)
/ >🐰 Curious about your priorities for this PR


✏️ Learnings added
Learnt from: ItzNotABug
PR: appwrite/appwrite#9752
File: app/config/collections/platform.php:1423-1423
Timestamp: 2025-05-13T12:02:08.046Z
Learning: In the Appwrite database schema, field names like 'resourceInternalId'/'resourceType' and 'deploymentInternalId'/'deploymentResourceType' are functionally equivalent and can coexist in the codebase without causing errors. The docker build and stack work fine with these naming inconsistencies.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
github-actions bot commented May 13, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
sqlite-libs 3.45.3-r1 CVE-2025-29087 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
github-actions bot commented May 13, 2025

✨ Benchmark results

  • Requests per second: 895
  • Requests with 200 status code: 161,091
  • P99 latency: 0.208252725

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 895 1,259
200 161,091 226,650
P99 0.208252725 0.146319461

@Meldiron Meldiron merged commit 39e0831 into 1.7.x May 13, 2025
149 of 150 checks passed
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
0