Skip to content

Custom disposition#10867

Merged
abnegate merged 2 commits into1.8.xfrom
feat-jwt-disposition
Nov 25, 2025
Merged

Custom disposition#10867
abnegate merged 2 commits into1.8.xfrom
feat-jwt-disposition

Conversation

@abnegate
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 Nov 25, 2025

📝 Walkthrough

Walkthrough

Storage controller response now sets Content-Disposition dynamically by reading a disposition claim from a decoded JWT (falls back to inline). The migrations worker includes a disposition: "attachment" claim when generating JWTs for CSV export downloads. composer.json dependency constraint for utopia-php/migration was tightened from 1.* to 1.3.*. One test file shows a formatting-only change to a numeric timeout literal.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify JWT decoding and fallback to inline in the storage controller.
  • Ensure the disposition claim is set as expected in the migrations JWT payload.
  • Confirm the Content-Disposition header is formatted correctly (e.g., inline vs attachment) and safely injected.
  • Check composer.json constraint bump for compatibility with the codebase.
  • Note: tests only contain a cosmetic numeric-literal formatting change.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description contains only the repository's contribution template with placeholder sections and no actual implementation details about the changes made. Replace the template placeholders with meaningful descriptions of what the PR does, how it was tested, and any related issues or PRs.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Custom disposition' directly relates to the main changes: introducing dynamic Content-Disposition headers derived from JWT claims instead of hardcoded values across API storage and migration flows.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 feat-jwt-disposition

📜 Recent 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 8fe7de7 and 448e604.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • composer.json (1 hunks)
  • tests/e2e/Services/Migrations/MigrationsBase.php (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/e2e/Services/Migrations/MigrationsBase.php
⏰ 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: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (1)
composer.json (1)

66-66: The version constraint is valid and already locked in the repository.

The composer.lock file confirms that utopia-php/migration version 1.3.3 exists and is already pinned (commit 731b3a963c58c30e0b2368695d57a7e8fcb7455c, released 2025-10-28). The constraint 1.3.* in composer.json correctly reflects this production dependency and is justified.

Likely an incorrect or invalid review comment.


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 Nov 25, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
imagemagick 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-c++ 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-dev 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-heic 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jpeg 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jxl 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-libs 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-openexr 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-webp 7.1.2.3-r0 CVE-2025-62171 HIGH
libecpg 17.6-r0 CVE-2025-12818 HIGH
libecpg-dev 17.6-r0 CVE-2025-12818 HIGH
libpq 17.6-r0 CVE-2025-12818 HIGH
libpq-dev 17.6-r0 CVE-2025-12818 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
postgresql17-dev 17.6-r0 CVE-2025-12818 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-47907 HIGH
stdlib 1.22.10 CVE-2025-58183 HIGH
stdlib 1.22.10 CVE-2025-58186 HIGH
stdlib 1.22.10 CVE-2025-58187 HIGH
stdlib 1.22.10 CVE-2025-58188 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 (1)
app/controllers/api/storage.php (1)

1511-1571: Deriving Content‑Disposition from JWT is correct; consider whitelisting values

Using a JWT claim to drive Content-Disposition and defaulting to inline preserves existing behavior and lets CSV exports opt into attachment, which looks good.

To harden this a bit and avoid unexpected or malformed dispositions from any future issuer of these JWTs, you could constrain the value to a small allow‑list before using it in the header, e.g.:

-    $isInternal = $decoded['internal'] ?? false;
-    $disposition = $decoded['disposition'] ?? 'inline';
+    $isInternal = $decoded['internal'] ?? false;
+    $disposition = $decoded['disposition'] ?? 'inline';
+    $allowedDispositions = ['inline', 'attachment'];
+    if (!\in_array($disposition, $allowedDispositions, true)) {
+        $disposition = 'inline';
+    }

Header construction can remain as is:

->addHeader('Content-Disposition', $disposition . '; filename="' . $file->getAttribute('name', '') . '"')

This keeps the new feature but prevents accidental introduction of odd or invalid disposition tokens.

📜 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 8e70a52 and 8fe7de7.

📒 Files selected for processing (2)
  • app/controllers/api/storage.php (2 hunks)
  • src/Appwrite/Platform/Workers/Migrations.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/controllers/api/storage.php (2)
tests/e2e/Client.php (1)
  • addHeader (161-166)
src/Appwrite/Utopia/Response.php (1)
  • file (841-848)
⏰ 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: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (1)
src/Appwrite/Platform/Workers/Migrations.php (1)

520-529: CSV export JWT disposition claim is consistent and backward‑compatible

Adding 'disposition' => 'attachment' here cleanly enables download behavior for CSV exports while preserving default inline semantics for any existing tokens that lack this claim. No issues spotted.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 25, 2025

✨ Benchmark results

  • Requests per second: 1,198
  • Requests with 200 status code: 215,692
  • P99 latency: 0.162446218

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,198 1,219
200 215,692 219,532
P99 0.162446218 0.169928332

@abnegate abnegate merged commit c6e4afd into 1.8.x Nov 25, 2025
40 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.

1 participant