Allow running tests with specific response format#10418
Conversation
📝 WalkthroughWalkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.17)Note: Using configuration file /phpstan.neon. If the excluded path can sometimes exist, append (?) parameters: ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
tests/e2e/Client.php (1)
111-123: Trim and ignore empty values to harden the API.Guard against accidental whitespace or empty strings so callers don’t have to.
Apply this diff:
public function setResponseFormat(string $value): self { - $this->addHeader('X-Appwrite-Response-Format', $value); + $value = trim($value); + if ($value === '') { + return $this; + } + $this->addHeader('X-Appwrite-Response-Format', $value); return $this; }tests/e2e/Scopes/Scope.php (1)
28-31: Avoid PHP’s empty('0') pitfall; trim input.Using empty() can skip valid “0”-like values. Prefer strict check against empty string after trim.
Apply this diff:
- $format = System::getEnv('_APP_E2E_RESPONSE_FORMAT'); - if (!empty($format)) { + $format = trim((string) System::getEnv('_APP_E2E_RESPONSE_FORMAT')); + if ($format !== '') { $this->client->setResponseFormat($format); }.github/workflows/tests.yml (2)
111-114: Use non-interactive exec (-T) for CI consistency.Most other execs use -T; align unit tests to avoid tty allocation quirks.
Apply this diff:
- docker compose exec \ + docker compose exec -T \ -e _APP_E2E_RESPONSE_FORMAT="${{ github.event.inputs.response_format }}" \ appwrite test /usr/src/code/tests/unit
521-521: Add trailing newline at EOF.Fix YAMLlint “no new line at end of file”.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.github/workflows/tests.yml(10 hunks)tests/e2e/Client.php(1 hunks)tests/e2e/Scopes/Scope.php(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/e2e/Scopes/Scope.php (1)
tests/e2e/Client.php (1)
setResponseFormat(118-123)
🪛 YAMLlint (1.37.1)
.github/workflows/tests.yml
[error] 521-521: no new line character at the end of file
(new-line-at-end-of-file)
⏰ 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: Check if utopia-php/database changed
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
🔇 Additional comments (11)
tests/e2e/Client.php (2)
111-123: New setter is consistent and chainable.Matches the existing pattern (e.g., setMode) and cleanly scopes the header.
111-123: Confirm server-side handling of X-Appwrite-Response-Format header valueClient::addHeader lowercases both header names and values (tests/e2e/Client.php 161–163); verify that the server’s code reading X-Appwrite-Response-Format treats lowercase values the same way (e.g. when matching against semver or _APP_SYSTEM_RESPONSE_FORMAT). If parsing is case-sensitive, normalize or canonicalize the header value before comparison.
tests/e2e/Scopes/Scope.php (1)
10-10: Import looks correct.System::getEnv is the right choice here for parity with other tests.
.github/workflows/tests.yml (8)
11-19: workflow_dispatch input wiring LGTM.Optional string input with sensible default; safe on pull_request runs (expands to empty).
146-150: Propagating response format to General E2E tests is correct.Non-interactive (-T) used; good.
222-226: Env passthrough for Services matrix looks good.Consistent with other jobs; won’t affect runs when input is empty.
311-315: Shared-mode Services wiring LGTM.Variable present across both table modes.
353-357: Dev Keys job uses the env consistently.No issues.
409-413: Shared-mode Dev Keys wiring LGTM.Matches Services job pattern.
452-456: Screenshots job wiring LGTM.Environment propagation consistent.
509-513: Shared-mode Screenshots wiring LGTM.No changes needed.
✨ Benchmark results
⚡ Benchmark Comparison
|
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
tests/e2e/Scopes/Scope.php (1)
28-28: Add discoverability for the new env var.
Please add_APP_E2E_RESPONSE_FORMATto the .env example and docs.
🧹 Nitpick comments (1)
tests/e2e/Scopes/Scope.php (1)
28-37: Harden env parsing and error messaging.
Trim the value, avoid empty() edge cases, and surface the invalid value with a more specific exception type.- $format = System::getEnv('_APP_E2E_RESPONSE_FORMAT'); - if (!empty($format)) { + $format = \trim((string) System::getEnv('_APP_E2E_RESPONSE_FORMAT')); + if ($format !== '') { if ( !\preg_match('/^\d+\.\d+\.\d+$/', $format) || !\version_compare($format, APP_VERSION_STABLE, '<=') ) { - throw new \Exception('E2E response format must be ' . APP_VERSION_STABLE . ' or lower.'); + throw new \InvalidArgumentException( + "Invalid E2E response format '{$format}'. Must be <= " . APP_VERSION_STABLE . '.' + ); } $this->client->setResponseFormat($format); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/e2e/Scopes/Scope.php(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/e2e/Scopes/Scope.php (1)
tests/e2e/Client.php (1)
setResponseFormat(118-123)
⏰ 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). (18)
- GitHub Check: E2E Service Test (VCS)
- GitHub Check: E2E Service Test (Webhooks)
- GitHub Check: E2E Service Test (Messaging)
- GitHub Check: E2E Service Test (Functions)
- GitHub Check: E2E Service Test (Realtime)
- GitHub Check: E2E Service Test (FunctionsSchedule)
- GitHub Check: E2E Service Test (Projects)
- GitHub Check: E2E Service Test (GraphQL)
- GitHub Check: E2E Service Test (Account)
- GitHub Check: E2E Service Test (Databases/TablesDB)
- GitHub Check: E2E Service Test (Avatars)
- GitHub Check: E2E Service Test (Databases/Legacy)
- GitHub Check: E2E Service Test (Site Screenshots)
- GitHub Check: E2E Service Test (Dev Keys)
- GitHub Check: E2E General Test
- GitHub Check: Unit Test
- GitHub Check: Benchmark
- GitHub Check: scan
🔇 Additional comments (2)
tests/e2e/Scopes/Scope.php (2)
10-10: Import is appropriate and scoped correctly.
No concerns with introducing Utopia\System\System here.
31-34: Ensure APP_VERSION_STABLE is loaded in your test bootstrap
APP_VERSION_STABLE is defined in app/init/constants.php (via app/init.php) but I didn’t find a test‐specific bootstrap under tests/. Add a require/import of app/init.php (or the constants file) in your test bootstrap to avoid undefined‐constant errors in CI.
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
Checklist