Skip to content

fix: filter Sites build runtimes by _APP_SITES_RUNTIMES - #12840

Merged
ChiragAgg5k merged 5 commits into
mainfrom
fix-sites-runtimes-allowlist
Jul 13, 2026
Merged

ChiragAgg5k merged 5 commits into
mainfrom
fix-sites-runtimes-allowlist

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Self-hosted Sites settings showed all build runtimes (including Bun/Deno/uninstalled Node versions) in the Console dropdown, while Functions correctly filters by _APP_FUNCTIONS_RUNTIMES.

This mirrors the Functions listRuntimes behavior for Sites:

  • GET /v1/sites/frameworks now filters each framework's runtimes list against _APP_SITES_RUNTIMES
  • Site create/update reject a buildRuntime that is not in the allowlist (when the allowlist is set)

Reported in community threads: https://appwrite.io/threads/1525087225895718983

Test Plan

  1. Set _APP_SITES_RUNTIMES=static-1,node-22,node-24 (leave Bun/Deno out)
  2. Restart Appwrite
  3. Open a Site → Settings → Runtime settings
  4. Confirm the build runtime dropdown only lists runtimes from the allowlist (same idea as Functions)
  5. Attempt create/update with a runtime outside the allowlist via API → expect general_argument_invalid

Related PRs and Issues

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?

listFrameworks was returning every framework runtime, so the Console
showed uninstalled options unlike Functions. Filter against the env
allowlist and reject unsupported buildRuntime on create/update.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a gap where Sites build runtimes were not filtered by _APP_SITES_RUNTIMES, mirroring the existing behavior in the Functions listRuntimes endpoint. All three layers of the fix — framework list filtering, site creation, and site update — are correctly implemented, and the previously flagged concern about frameworks with all runtimes filtered out is addressed.

  • XList.php: filters each framework's runtimes array against the allowlist, drops frameworks left with an empty runtimes list, and updates the default buildRuntime to the first available allowed entry.
  • Create.php / Update.php: add a secondary allowlist check after the existing WhiteList param validator, throwing GENERAL_ARGUMENT_INVALID when the supplied buildRuntime is outside _APP_SITES_RUNTIMES. Update correctly guards against an empty buildRuntime (optional param) while Create does not need that guard (required param).
  • SitesCustomServerTest.php: adds a failure-path assertion using node-24, which exists in appwrite/php-runtimes v0.20+ (passes the global WhiteList validator) but is absent from the test env's _APP_SITES_RUNTIMES=static-1,node-22, so it correctly exercises the new allowlist check.

Confidence Score: 5/5

  • Safe to merge — the changes are narrowly scoped, correctly mirror the Functions pattern, and introduce no new code paths that could break existing sites when the allowlist is not configured.
  • All three changed files implement the same straightforward allowlist guard. The XList filtering correctly handles edge cases (empty-runtime frameworks, default buildRuntime alignment). The Create/Update asymmetry around the empty-string guard is intentional and correct. The test uses a runtime (node-24) that is present in the global runtime library but absent from the test env allowlist, so it genuinely exercises the new check rather than being caught by the earlier WhiteList validator.
  • No files require special attention.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php Filters each framework's runtime list against _APP_SITES_RUNTIMES; drops frameworks with no remaining runtimes and updates the default buildRuntime to the first allowed entry. Logic is correct and the previous concern about empty-runtime frameworks is addressed.
src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php Adds a secondary allowlist check after the WhiteList param validator; throws GENERAL_ARGUMENT_INVALID when buildRuntime is not in _APP_SITES_RUNTIMES. The check correctly fires only when the allowlist is non-empty.
src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php Mirrors the Create.php allowlist check; correctly adds the !empty($buildRuntime) guard since buildRuntime is optional in updates (defaults to empty string when not supplied).
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds a failure-path test using node-24, which is present in the global runtimes list (appwrite/php-runtimes v0.20+) but absent from the test env's _APP_SITES_RUNTIMES=static-1,node-22, correctly exercising the new allowlist check.

Reviews (5): Last reviewed commit: "test: cast sites allowlist assertion mes..." | Re-trigger Greptile

Comment thread src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php
After filtering by _APP_SITES_RUNTIMES, drop frameworks whose runtime
list is empty so the Console does not offer unusable options.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-sites-runtimes-allowlist (after).

Metric Before After Change
🚀 Requests/sec 112.78 110.19 -2.3%
⏱️ Latency P50 120.54 ms 121.48 ms +0.8%
⏱️ Latency P95 462.59 ms 495.04 ms 🔴 +7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 121.48 495.04 7,068 110.19 +32.45
Account 219.36 608.43 372 6.15 -30.83
TablesDB 107.44 427.32 3,844 61.11 +29.01
Storage 115.76 552.47 1,860 31.39 +65.12
Functions 193.78 535.9 992 17.53 +2.45

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.increment 1,306.86
tokens.files.list 1,303.04
functions.variables.update 1,276.55
storage.files.create 1,268.49
tokens.files.create 1,227.37

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit d0d1ab0 - 1 flaky test
Test Retries Total Time Details
RealtimeConsoleClientTest::testIndexesTablesAPI 1 249ms Logs
Commit a75d95a - 1 flaky test
Test Retries Total Time Details
FunctionsServerTest::testCreateExecution 1 81ms Logs

ChiragAgg5k and others added 3 commits July 10, 2026 17:28
If the default buildRuntime is excluded by _APP_SITES_RUNTIMES, point it
at the first remaining enabled runtime so clients do not preselect an
invalid value.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
$allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', ''))));

if (!empty($allowList) && !\in_array($buildRuntime, $allowList, true)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Runtime "' . $buildRuntime . '" is not supported');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might want similar throw in builds worker, maybe even general.php router()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point — I looked into this. Functions also only enforces _APP_FUNCTIONS_RUNTIMES at Create + list (not in the Builds worker or general.php router for v5); those paths just resolve against the full runtimes catalog. Sites now mirrors that at Create/Update + frameworks list, and the executor still gates via OPR_EXECUTOR_RUNTIMES. Happy to add worker/router allowlist checks for both Functions and Sites as a follow-up if we want that extra defense-in-depth.

@ChiragAgg5k
ChiragAgg5k merged commit b8bc11f into main Jul 13, 2026
52 of 56 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix-sites-runtimes-allowlist branch July 13, 2026 08:00
ItzNotABug pushed a commit to ItzNotABug/appwrite that referenced this pull request Jul 23, 2026
…lowlist

fix: filter Sites build runtimes by _APP_SITES_RUNTIMES
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.

2 participants