Skip to content

fix(api): report an unavailable cache as a 503 - #14863

Merged
abnegate merged 2 commits into
mainfrom
fix/cache-unavailable-503
Oct 23, 2026
Merged

abnegate merged 2 commits into
mainfrom
fix/cache-unavailable-503

Conversation

@abnegate

Copy link
Copy Markdown
Member

Problem

Since #14642, a purge the cache circuit breaker cannot confirm throws Utopia\Cache\Exception\Unavailable. The error hook in app/controllers/general.php has no case for it, so it reaches clients as a 500 general_unknown that SDKs do not retry.

In Appwrite Cloud this happens on /v1/regions/cache and on any write whose post-commit purge fails. On 2026-10-22 22:30Z one Dragonfly reload in nyc produced a burst of these: CLOUD-3RB2, CLOUD-3R9E, CLOUD-3R9M.

Fix

Map Unavailable to a new general_cache_unavailable error (503). This is the mapping half of #14643, which now conflicts with main. The other half of #14643, making save/saveMany throw, is left out (see below).

The description does not say the request was "not applied". A purge that runs after the commit can fail too, so the client is told to read the affected resources back before retrying.

Not included: throwing from save

#14643 also makes a refused save throw. utopia-php/database#1041 now depends on save returning false for cache-owner registration: when registration fails, the write continues behind a tombstone. A throwing save would refuse that write instead. That half needs rethinking against the current database design before it lands.

Tests

No unit test: the mapping lives in the error-hook closure, and an E2E would need the cache to fail mid-request. The new error code is documented in the response-codes table.

🤖 Generated with Claude Code

Since #14642, a purge the circuit breaker cannot confirm throws
Utopia\Cache\Exception\Unavailable. The error hook had no case for it,
so it reached clients as a 500 general_unknown that SDKs do not retry.
Map it to a new general_cache_unavailable (503).

It is not described as "not applied": a purge after the commit can fail
too, so the client is told to read the affected resources back before
retrying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change introduces a new public error code for when the cache backend is unavailable, mapping the cache's Unavailable exception to a 503 response. The code is registered consistently across all layers: the constant on Appwrite\Extend\Exception, the app/config/errors.php map with its message and 503 status, the router case in app/controllers/general.php, and a matching row in the console response-codes documentation. No defects were found in the mapping, ordering, or contract consistency.

Files Change
src/Appwrite/Extend/Exception.php Adds the GENERAL_CACHE_UNAVAILABLE error-code constant.
app/config/errors.php Registers the error with its 503 status and user-facing message.
app/controllers/general.php Adds the router case translating the cache unavailability exception into the new error.
apps/console/src/content/docs/apis/response-codes/index.markdoc Documents the new 503 code in the public response-codes table.

Reviewed commit: 0854e48

@appwrite

appwrite Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

New Console

Project ID: new-console

Sites (1)
Site Status Logs Preview QR
 New Console
new-console
Ready Ready View Logs Preview URL QR Code

Tip

Each function runs in its own isolated container with custom environment variables

@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Maps Utopia\Cache\Exception\Unavailable to the new general_cache_unavailable API error with HTTP 503. Adds the error description to server configuration and the Console response-code documentation, advising clients to read affected resources before retrying.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 4
File Change
app/config/errors.php Defines the new cache-unavailable error description and 503 status.
app/controllers/general.php Maps cache Unavailable exceptions to general_cache_unavailable.
apps/console/src/content/docs/apis/response-codes/index.markdoc Documents the new 503 response code.
src/Appwrite/Extend/Exception.php Adds the constant for the new general error type.

Merged main (d63021b); no changes to this PR's code since 0854e48 · 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 S · Looks good to merge. Summary

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@14863

commit: 0e633dd

@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 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/cache-unavailable-503 (after).

Metric Before After Change
🚀 Requests/sec 211.64 216.42 ⚪ +2.3%
⏱️ Latency P50 79.41 ms 81 ms ⚪ +2%
⏱️ Latency P95 187.04 ms 187.25 ms ⚪ +0.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 81 187.25 13,680 216.42 +0.21
Account 148.71 285.9 720 12.17 -5.11
TablesDB 78.25 148.05 7,440 120.14 -2.17
Storage 75 169.94 3,600 59.7 -8.69
Functions 109.8 216.6 1,920 32.46 +13.42

Top API waits (after)

API request Max wait (ms)
account.name.update 495.54
account.prefs.update 426.23
tablesdb.rows.create 392.24
functions.create 346.59
storage.buckets.create 336.4

@abnegate
abnegate merged commit 965de7b into main Oct 23, 2026
74 checks passed
@abnegate
abnegate deleted the fix/cache-unavailable-503 branch October 23, 2026 04:05
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…-503

fix(api): report an unavailable cache as a 503

(cherry picked from commit 965de7b)
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