Skip to content

fix(proxy): reserve the functions fallback domain for rules - #15025

Merged
ChiragAgg5k merged 4 commits into
mainfrom
fix/functions-fallback-domain
Oct 27, 2026
Merged

ChiragAgg5k merged 4 commits into
mainfrom
fix/functions-fallback-domain

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Rules may no longer claim the functions fallback base domain or hosts nested under it, matching the functions domain. The router now refuses reserved base domains before looking up a rule, so an existing rule cannot serve one.

The router answers a reserved host with an HTML error page, which json_encode could not serialise, so the assertion compared against an empty string.

Lint, PHPStan and the touched unit tests passed locally before rebasing on main; e2e runs in CI.

Related: appwrite-labs/cloud#6674

Rules may no longer claim the functions fallback base domain or hosts nested
under it, matching the functions domain. The router now refuses reserved base
domains before looking up a rule, so an existing rule cannot serve one.
The router answers a reserved host with an HTML error page, which json_encode
could not serialise, so the assertion compared against an empty string.
@luxor-code-review

luxor-code-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to

🟡 Medium — Register _APP_DOMAIN_FUNCTIONS_FALLBACK in env catalog · app/config/variables.php

The new _APP_DOMAIN_FUNCTIONS_FALLBACK variable is added to .env and the appwrite service env list in docker-compose.yml:146, but the variable catalog at app/config/variables.php was not given a matching entry, even though the sibling _APP_DOMAIN_FUNCTIONS is defined there at line 147. Installer-driven self-hosted installs will therefore never generate the variable, so System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', '') resolves to empty and silently disables the fallback-domain restriction the PR adds. The same omission applies to the ConsoleVariables response model (src/Appwrite/Utopia/Response/Model/ConsoleVariables.php), leaving the variable out of the console's environment listing.


This change introduces an additional reserved base domain for function subdomains, defaulting to fallback.localhost, wired through .env and the appwrite service in docker-compose.yml. Proxy request routing now rejects reserved base domains (the primary functions./sites. hosts plus the fallback) up front — including when an actual rule matches — returning GENERAL_ACCESS_FORBIDDEN for base domains and rule-not-found behavior for non-reserved subdomains. The proxy rule validator (Action.php) appends the fallback domain to the restriction list so rules may only target one subdomain level under it. E2E tests in ProxyBase.php cover both the allowed single-level fallback subdomain and the denied base/nested cases via the raw proxy client.

Files Change
.env, docker-compose.yml Add _APP_DOMAIN_FUNCTIONS_FALLBACK default and pass it to the appwrite container
app/controllers/general.php Deny requests to reserved base domains (with rule present or not) during proxy routing
src/Appwrite/Platform/Modules/Proxy/Action.php Extend rule domain-restriction validation with the fallback domain
tests/e2e/Services/Proxy/ProxyBase.php Add e2e cases for fallback-domain restriction allow/deny paths

Reviewed commit: f7c9885

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 27, 2026
@ghost

ghost commented Oct 27, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The open CTA regression is fixed, and the incremental change introduces no other issues.

The PR reserves the functions fallback base domain and its nested hosts from proxy rules, and adds fallback-domain configuration plus router checks to enforce that behavior. It also adds Proxy E2E coverage for rule validation and reserved-host requests.

Latest changes: The latest commit only runs the deep-fallback-host rejection when a matching rule exists, allowing unconfigured hosts to continue to the existing error path and CTA.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 5
File Change
.env Sets the local functions fallback domain.
docker-compose.yml Passes the fallback-domain setting to the app container.
src/Appwrite/Platform/Modules/Proxy/Action.php Applies functions-domain restrictions when validating fallback domains.
app/controllers/general.php Rejects reserved base domains and prevents matching legacy rules from serving deeper fallback hosts; the latest change preserves the CTA path when no rule matches.
tests/e2e/Services/Proxy/ProxyBase.php Covers fallback-domain rule validation and requests to reserved hosts.
✅ Fixed since the last review · 1
  • Preserve the fallback-domain CTA when no rule exists · app/controllers/general.php:131

Reviewed the commits since 731d6d2 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread app/controllers/general.php Resolved
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/functions-fallback-domain (after).

Metric Before After Change
🚀 Requests/sec 195.16 207.16 🟢 +6.1%
⏱️ Latency P50 86.87 ms 85.84 ms ⚪ -1.2%
⏱️ Latency P95 213.12 ms 189.52 ms 🟢 -11.1%
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 85.84 189.52 12,768 207.16 -23.6
Account 150.41 287.21 672 11.15 -21.75
TablesDB 84.92 156.27 6,944 114.18 -11.61
Storage 75.28 179.59 3,360 57.63 -13.81
Functions 108.79 212.54 1,792 31.46 -17.84

Top API waits (after)

API request Max wait (ms)
account.name.update 423.37
functions.create 407.62
account.prefs.update 404.4
storage.buckets.create 393.32
tablesdb.rows.decrement 347.49

Rules can no longer be created for nested hosts under the functions
fallback domain, but a rule saved before that limit would still be
served. The router now refuses those hosts before using a rule.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread app/controllers/general.php Resolved
Hosts without a rule keep the existing not-found error with its setup
link.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 463ffac into main Oct 27, 2026
71 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/functions-fallback-domain branch October 27, 2026 19:18
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