Skip to content

Conversation

@lohanidamodar
Copy link
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
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Added app/config/cors.php with centralized CORS settings and loaded it during bootstrap via Config::load in app/init/configs.php. The HTTP/CORS resource in app/init/resources.php now reads the cors config and constructs the Cors instance from allowedMethods, allowedHeaders, and exposedHeaders (resource callback changed from an arrow fn to a function and now registers ['allowedHostnames']). tests/e2e/General/HTTPTest.php was updated to read CORS values from Config::getParam('cors') and assert response headers against those config-derived values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description contains only the template boilerplate with no substantive explanation of the changes, objectives, test plan, or motivation for the CORS-related modifications. Replace the template with a concrete description explaining the CORS configuration centralization, why it's needed, and how to test the changes.
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.
Title check ❓ Inconclusive The title 'Chore: tests' is vague and generic, failing to convey the actual changes which involve implementing centralized CORS configuration across multiple files. Use a more descriptive title like 'Chore: centralize CORS configuration' to clearly indicate the primary change in the changeset.

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

✨ 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 chore-tests

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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 Feb 10, 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
libcrypto3 3.5.4-r0 CVE-2025-69421 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
libssl3 3.5.4-r0 CVE-2025-69421 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
openssl 3.5.4-r0 CVE-2025-15467 CRITICAL
openssl 3.5.4-r0 CVE-2025-69419 HIGH
openssl 3.5.4-r0 CVE-2025-69421 HIGH
openssl-dev 3.5.4-r0 CVE-2025-15467 CRITICAL
openssl-dev 3.5.4-r0 CVE-2025-69419 HIGH
openssl-dev 3.5.4-r0 CVE-2025-69421 HIGH
py3-urllib3 1.26.20-r0 CVE-2026-21441 HIGH
py3-urllib3-pyc 1.26.20-r0 CVE-2026-21441 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-68121 CRITICAL
stdlib 1.22.10 CVE-2025-47907 HIGH
stdlib 1.22.10 CVE-2025-58183 HIGH
stdlib 1.22.10 CVE-2025-61726 HIGH
stdlib 1.22.10 CVE-2025-61728 HIGH
stdlib 1.22.10 CVE-2025-61729 HIGH
stdlib 1.22.10 CVE-2025-61730 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link

github-actions bot commented Feb 10, 2026

✨ Benchmark results

  • Requests per second: 2,157
  • Requests with 200 status code: 388,245
  • P99 latency: 0.073035611

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 2,157 1,096
200 388,245 197,389
P99 0.073035611 0.190366157

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: 1

🤖 Fix all issues with AI agents
In `@app/config/cors.php`:
- Line 9: The CORS config's allowedMethods array ('allowedMethods') is missing
HEAD, causing cross-origin HEAD requests to fail; update the 'allowedMethods'
array in app/config/cors.php (the 'allowedMethods' entry) to include 'HEAD' so
it becomes ['GET','POST','PUT','PATCH','DELETE','HEAD'] to match supported HEAD
requests referenced in tests/e2e/Client.php and the Functions execution module
whitelist.
🧹 Nitpick comments (1)
tests/e2e/General/HTTPTest.php (1)

32-41: Test asserts against the same source of truth it's verifying — consider the trade-off.

The test now reads from Config::getParam('cors') and asserts the response headers match. This ensures consistency with the config but won't catch if the config itself has incorrect/missing values (e.g., a required header accidentally removed). Previously, hardcoded values in the test served as an independent second source of truth.

This is an acceptable trade-off for maintainability, just worth being aware of.

* Centralised list of allowed methods, headers, and exposed headers for CORS responses.
*/
return [
'allowedMethods' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if HEAD method is used/handled in routes
rg -n --type=php -i 'HEAD|head.*method|method.*head' -C2 | head -60

Repository: appwrite/appwrite

Length of output: 3927


🏁 Script executed:

# Search for CORS-related handling and middleware
rg -n --type=php 'cors|CORS|allowedMethods' -C2 | head -80

Repository: appwrite/appwrite

Length of output: 4768


🏁 Script executed:

# Look at the Cors class implementation if it exists
fd -e php -i cors | head -20

Repository: appwrite/appwrite

Length of output: 142


🏁 Script executed:

# Check the app/config/cors.php file to see the complete context
cat -n app/config/cors.php

Repository: appwrite/appwrite

Length of output: 1702


🏁 Script executed:

# Read the Cors.php implementation
cat -n src/Appwrite/Network/Cors.php | head -100

Repository: appwrite/appwrite

Length of output: 3992


🏁 Script executed:

# Check if there's any framework-level HEAD method handling
rg -n 'HEAD|Method::HEAD' --type=php | head -40

Repository: appwrite/appwrite

Length of output: 4841


🏁 Script executed:

# Look at the routing/framework setup to understand how methods are handled
fd -e php -type f | xargs grep -l "Route\|Request.*method" | head -10

Repository: appwrite/appwrite

Length of output: 231


🏁 Script executed:

# Check if OPTIONS method is used/needed for CORS preflight
rg -n "OPTIONS|preflight" --type=php | head -30

Repository: appwrite/appwrite

Length of output: 3937


🏁 Script executed:

# Look at the Swagger2 file to see how HEAD is being handled
cat -n src/Appwrite/SDK/Specification/Format/Swagger2.php | head -130

Repository: appwrite/appwrite

Length of output: 5638


🏁 Script executed:

# Check if there are any routes explicitly handling HEAD method at route registration level
rg -n "Method.*HEAD|method.*HEAD|->get\(|->post\(|->method" app/controllers --type=php | head -30

Repository: appwrite/appwrite

Length of output: 2536


🏁 Script executed:

# Look for any documentation or comments about HEAD request support
rg -n -i "head.*request|request.*head" --type=php | head -20

Repository: appwrite/appwrite

Length of output: 3142


Add HEAD to the allowedMethods array.

The application explicitly supports HEAD requests (evidenced by test cases in tests/e2e/Client.php and tests/e2e/Services/Functions/FunctionsCustomServerTest.php, and the Functions execution module's whitelist), but the CORS configuration does not declare HEAD as allowed. This will cause cross-origin HEAD requests to fail with CORS preflight errors. Update line 9 to include HEAD:

'allowedMethods' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'],
🤖 Prompt for AI Agents
In `@app/config/cors.php` at line 9, The CORS config's allowedMethods array
('allowedMethods') is missing HEAD, causing cross-origin HEAD requests to fail;
update the 'allowedMethods' array in app/config/cors.php (the 'allowedMethods'
entry) to include 'HEAD' so it becomes
['GET','POST','PUT','PATCH','DELETE','HEAD'] to match supported HEAD requests
referenced in tests/e2e/Client.php and the Functions execution module whitelist.

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