Skip to content

Get cursor queries#11201

Open
fogelito wants to merge 3 commits into1.8.xfrom
get-cursor-queries
Open

Get cursor queries#11201
fogelito wants to merge 3 commits into1.8.xfrom
get-cursor-queries

Conversation

@fogelito
Copy link
Contributor

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
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

This pull request centralizes cursor extraction across multiple API controllers and HTTP handlers by replacing inline cursor-filtering logic (previously using array_filter + reset) with Query::getCursorQueries($queries, false) and normalizing the result via reset(). Conditional checks were changed from truthy evaluations to explicit comparisons against false (if ($cursor !== false)). Existing cursor validation and subsequent document resolution/error paths were preserved. No public API signatures were modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
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.
Description check ❓ Inconclusive The description is an empty template with no substantive content explaining the PR's purpose, motivation, test plan, or related issues, making it impossible to verify relevance to the changeset. Complete the PR description by explaining the motivation for the cursor queries refactoring, providing a test plan, and referencing any related issues or discussions.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Get cursor queries' directly corresponds to the main refactoring across all files: introducing a centralized Query::getCursorQueries() helper to replace manual cursor extraction logic.

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

✨ 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

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

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libcrypto3 3.5.4-r0 CVE-2025-15467 CRITICAL
libcrypto3 3.5.4-r0 CVE-2025-69419 HIGH
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng 1.6.51-r0 CVE-2026-22695 HIGH
libpng 1.6.51-r0 CVE-2026-22801 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2026-22695 HIGH
libpng-dev 1.6.51-r0 CVE-2026-22801 HIGH
libssl3 3.5.4-r0 CVE-2025-15467 CRITICAL
libssl3 3.5.4-r0 CVE-2025-69419 HIGH
openssl 3.5.4-r0 CVE-2025-15467 CRITICAL
openssl 3.5.4-r0 CVE-2025-69419 HIGH
openssl-dev 3.5.4-r0 CVE-2025-15467 CRITICAL
openssl-dev 3.5.4-r0 CVE-2025-69419 HIGH
py3-urllib3 1.26.20-r0 CVE-2026-21441 HIGH
py3-urllib3-pyc 1.26.20-r0 CVE-2026-21441 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php (2)

72-85: Missing Cursor validator - inconsistent with other modules.

This file lacks the Cursor validation step that all other refactored files include. Other modules validate the cursor before extracting its value:

$validator = new Cursor();
if (!$validator->isValid($cursor)) {
    throw new Exception(Exception::GENERAL_QUERY_INVALID, $validator->getDescription());
}

Without this validation, invalid cursor queries may proceed and cause unexpected behavior downstream.

Proposed fix

Add the import and validation:

 use Utopia\Database\Database;
 use Utopia\Database\Document;
 use Utopia\Database\Query;
 use Utopia\Database\Validator\Authorization;
+use Utopia\Database\Validator\Query\Cursor;
 use Utopia\Database\Validator\UID;
 if ($cursor !== false) {
+    $validator = new Cursor();
+    if (!$validator->isValid($cursor)) {
+        throw new Exception(ExtendException::GENERAL_QUERY_INVALID, $validator->getDescription());
+    }
+
     $tokenId = $cursor->getValue();

21-23: Missing Action class import - code will fail at runtime.

The class extends Action on line 21, but there's no corresponding import statement. Other modules in this PR import it via use Utopia\Platform\Action;.

Proposed fix
 use Utopia\Database\Validator\Authorization;
 use Utopia\Database\Validator\UID;
+use Utopia\Platform\Action;
 use Utopia\Platform\Scope\HTTP;

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

✨ Benchmark results

  • Requests per second: 1,969
  • Requests with 200 status code: 354,501
  • P99 latency: 0.090857752

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,969 1,119
200 354,501 201,442
P99 0.090857752 0.186921261

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