Repository navigation
Description
Summary
Several endpoints accept values that their database columns can't hold. The request validator passes, createDocument/updateDocument throws Utopia\Database\Exception\Structure, nothing maps that exception, and the client gets a 500 general_unknown instead of a 400.
Two causes:
- Encrypted columns are sized for the plaintext. The
encryptfilter (app/init/database/filters.php:277-289) stores a JSON wrapper,{"data":<base64 ciphertext>,"method":"aes-128-gcm","iv":<24 hex>,"tag":<32 hex>,"version":"1"}. That adds 121 characters plus about 33% for base64, andjson_encodeescapes every/in the base64 as\/, so the stored length also varies randomly from one save to the next. - Validators allow more than the column holds, or set no length limit at all.
Reproduced on production
On Cloud (fra), 2026-10-09 10:13 UTC, using the Appwrite CLI against a test project. Every request returned 500 general_unknown and nothing was saved. All events are grouped under CLOUD-3R1X.
| Request | Validator | Column | Sentry event |
|---|---|---|---|
POST /v1/webhooks with a 120-char authPassword |
PasswordFormat(Text(256)) |
httpPass: 255, encrypt |
httpPass |
POST /v1/webhooks with a 256-char authUsername |
Text(256) |
httpUser: 255 |
httpUser |
POST /v1/webhooks with a 270-char url |
Multiple([URL, PublicDomain]), no length limit |
url: 255 |
url |
POST /v1/sites/:siteId/variables with a long value (seen in production, 27 events up to 2026-10-04) |
Text(8192) |
value: 8192, encrypt |
value |
appwrite webhooks create --webhook-id repro --name repro --url https://example.com/hook \
--events 'users.*.create' --auth-username mcp --auth-password "$(python3 -c "print('p'*120)")"
# → {"message":"Server Error","code":500,"type":"general_unknown"}Webhook authPassword: the real limit is about 99, not 256
| Password length | Base64 length | Stored length (column holds 255) |
|---|---|---|
| 96 | 128 | 249, plus 2 per escaped / |
| 99 | 132 | 253 |
| 100 | 136 | 257 ❌ |
| 256 (documented max) | 344 | 465 ❌ |
Escaped slashes mean passwords of about 90–99 characters fail at random, depending on the IV. No length under 255 is guaranteed to fit. There's a // TODO will the length suffice after encryption? on httpPass in app/config/collections/platform.php.
Variables value
Function and site variables have the same problem: Text(8192) against an encrypted 8192-character column (Functions/Http/Variables/{Create,Update}.php:63-64, Sites/Http/Variables/{Create,Update}.php:63-64, column in app/config/collections/common.php). A value of about 6000 characters or more overflows once encrypted.
Proposed fix
- Size encrypted columns for the ciphertext, not the plaintext. Make
httpPassand the variablesvaluecolumnVAR_TEXTwith size65535, as the VCS token columns already are (998e7a1). Add a migration step for existing columns. Do the same for any otherencryptcolumn whose validator allows more than about(size - 121) * 3/4 / 2characters. - Match validators to their columns.
authUsername→Text(255);url→ addText(255)to itsMultiplevalidator; update theMax lengthwording in the parameter docs and the SDK specs. - Safety net: map
Utopia\Database\Exception\StructuretoDOCUMENT_INVALID_STRUCTURE(400) in the general error handler, so any remaining mismatch becomes a 400 instead of a 500. CLOUD-3R1X shows this already happens across more than one endpoint. - Regression tests: extend the existing webhooks and variables e2e tests:
- a 256-character
authPasswordsucceeds and is delivered intact - 256-character
authUsernameandurlreturn 400 - an 8192-character variable
valuesucceeds
- a 256-character
Context
Found while building MCP Events for the hosted MCP server (appwrite/mcp#127). It stores a sealed subscription envelope in the webhook's authPassword. With the current limit, that envelope has to be split across three fields.
2026-10-12: Merged PR #14356 — sized webhooks.httpPass to VAR_TEXT, raised authPassword to 2048, mapped Structure → 400, and stabilized encrypt JSON. Remaining encrypted columns (variables value, etc.) still open here.
2026-10-12: Opened Cloud PR appwrite-labs/cloud#6481, bumping appwrite/server-ce to ship #14356 on Cloud, after appwrite-labs/cloud#6474 converted httpPass to text in production.
Activity
ChiragAgg5k commentedon Oct 9, 2026
Scoping note from the MCP side (appwrite/mcp#127, envelope in appwrite/mcp#132): widening the
httpPasscolumn alone isn't enough. TheauthPasswordrequest validator on webhook create/update isPasswordFormat(Text(256)), and the values we need to store are larger than 256 characters before encryption:authPasswordlengthSo the fix needs both:
httpPasscolumn →VAR_TEXT(65535), as in the issue, so the encrypted value always fits.authPasswordvalidator onPOST /v1/webhooksandPUT /v1/webhooks/:webhookId→ at leastText(2048)(and the "Max length" wording in the param docs/SDK specs).The same applies to the variables
valueparam if its column moves toVAR_TEXT: the validator and the column should agree on the plaintext limit.JoshiJoshiJoshi commentedon Oct 11, 2026
The same wrapper overhead also limits user columns with
encrypt: truein TablesDB. There it surfaces as a400with a misleading message instead of a500, because the structure validator checks the length of the encrypted JSON wrapper instead of the plaintext.Measured on self-hosted 2.4.0 (Postgres), binary search per column, two runs:
ä)varchar(150),encrypt(the minimum size for encryption)varchar(300),encryptvarchar(1000),encrypttext,encryptWriting exactly 150 characters into the
varchar(150)column fails withAttribute "e" has invalid type. Value must be a valid string and no longer than 150 chars.createRow,upsertRow,createRows,updateRowsand transactions behave the same. Usable length ≈ (size − 122) × ¾ for ASCII and half of that for multi-byte text.Sizing the stored column for the wrapper (or validating the plaintext against
sizeand the wrapper against the column) would fix both cases.feat: MCP Events behind the events flag (#136)
ChiragAgg5k commentedon Oct 14, 2026
Released in Appwrite 2.5.0 (includes #14356).