Skip to content

Tableid and Collectionid in increment and decrement routes#10952

Merged
abnegate merged 2 commits into1.8.xfrom
issue-tableid
Dec 16, 2025
Merged

Tableid and Collectionid in increment and decrement routes#10952
abnegate merged 2 commits into1.8.xfrom
issue-tableid

Conversation

@ArnabChatterjee20k
Copy link
Copy Markdown
Member

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?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 13, 2025

📝 Walkthrough

Walkthrough

This PR adds metadata attribution to increment and decrement operation responses. After successfully incrementing or decrementing a document attribute, the operations now set an additional field on the returned document containing the associated collection ID (for Collections/Documents) or table ID (for TablesDB). The implementation adds this attribute-setting logic to the post-success handlers in the Increment and Decrement classes. Corresponding test files are updated to verify that these new fields are present in the response payloads with correct values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Dynamic field naming verification: Confirm the $<context>Id pattern in Collections/Documents correctly resolves to the intended field names across both Increment and Decrement operations
  • Value assignment correctness: Validate that collectionId and tableId values are correctly sourced and assigned in both implementations and test contexts
  • Test assertion alignment: Ensure test assertions validate the exact field names and values that correspond to the implementation changes in both Legacy and TablesDB test files
  • Consistency across operations: Verify the pattern is consistently applied to both increment and decrement operations without missing either case

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is an unfilled contribution template with no actual content describing what the PR does, why it exists, or test plans. Provide a detailed description of the changes, explain the motivation, include a test plan with verification steps, and document any related issues or PRs.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 clearly describes the main change: adding tableId and collectionId to increment and decrement route responses.
✨ 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 issue-tableid

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 13, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

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 (4)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php (1)

172-181: Verify transaction-staging response uses the same $collectionId / $tableId key as the non-transaction response (and consider centralizing).

The new '$' . $this->getCollectionsEventsContext() . 'Id' attribute (Line 180) looks correct for the normal path, but the transactionId early-return path builds $mockDocument with '$' . $groupId (Line 159-165). Please confirm getGroupId() resolves to the same key (collectionId vs tableId) so staged vs non-staged responses don’t diverge. Also, this attribute-setting is duplicated in Decrement—consider a small helper to set it in one place.

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

6115-6122: Add an explicit key-presence assertion for clearer failures (increment response).
If '$collectionId' is missing, PHP array access can produce noisy notices and the failure message is less actionable; asserting presence first makes the test output cleaner.

         $this->assertEquals(200, $inc['headers']['status-code']);
         $this->assertEquals(6, $inc['body']['count']);
-        $this->assertEquals($collectionId, $inc['body']['$collectionId']);
+        $this->assertArrayHasKey('$collectionId', $inc['body']);
+        $this->assertEquals($collectionId, $inc['body']['$collectionId']);

6226-6234: Add an explicit key-presence assertion for clearer failures (decrement response).
Same rationale as increment: validate the response shape before asserting equality.

         $this->assertEquals(200, $dec['headers']['status-code']);
         $this->assertEquals(9, $dec['body']['count']);
-        $this->assertEquals($collectionId, $dec['body']['$collectionId']);
+        $this->assertArrayHasKey('$collectionId', $dec['body']);
+        $this->assertEquals($collectionId, $dec['body']['$collectionId']);
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (1)

7874-7877: Good coverage: validates $tableId is echoed in decrement response.
Optional: also assert $tableId on $inc2 / $dec2 to cover the non-default value paths.

📜 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 7d2a95c and e4e6c84.

📒 Files selected for processing (4)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php (1 hunks)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php (1 hunks)
  • tests/e2e/Services/Databases/Legacy/DatabasesBase.php (2 hunks)
  • tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.
🧬 Code graph analysis (2)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php (3)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php (1)
  • getCollectionsEventsContext (223-226)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php (1)
  • getCollectionsEventsContext (203-206)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Action.php (1)
  • getCollectionsEventsContext (151-154)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php (3)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php (1)
  • getCollectionsEventsContext (223-226)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php (1)
  • getCollectionsEventsContext (203-206)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Action.php (1)
  • getCollectionsEventsContext (151-154)
⏰ 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). (19)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Locale)
  • GitHub Check: E2E Service Test (Databases/Legacy)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (Migrations)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (Users)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Site Screenshots)
  • GitHub Check: E2E Service Test (Dev Keys)
  • GitHub Check: E2E General Test
  • GitHub Check: Unit Test
🔇 Additional comments (2)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php (1)

172-181: LGTM—mirrors Increment, but double-check staged vs non-staged response key consistency.

Setting '$' . $this->getCollectionsEventsContext() . 'Id' (Line 180) is consistent with the desired behavior (collection vs table context). Same note as Increment: please confirm the transactionId early-return path’s '$' . $groupId key matches this, so clients get the same field name in both modes.

tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (1)

7761-7764: Good coverage: validates $tableId is echoed in increment response.
This aligns the test with the intended TablesDB metadata behavior.

@github-actions
Copy link
Copy Markdown

✨ Benchmark results

  • Requests per second: 1,174
  • Requests with 200 status code: 211,324
  • P99 latency: 0.165433987

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,174 1,196
200 211,324 215,377
P99 0.165433987 0.172078984

@abnegate abnegate merged commit 8005738 into 1.8.x Dec 16, 2025
43 checks passed
@abnegate abnegate deleted the issue-tableid branch December 16, 2025 06:05
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.

3 participants