Skip to content

🐛 Bug Report: Postgres: a value too large for a column's index returns 500 #14335

Closed

Description

@JoshiJoshiJoshi

👟 Reproduction steps

  1. Create a table with a varchar column of size 700 and a key index on it (both accepted: the index length limit is 768).
  2. Create a row whose value is 700 random 4-byte characters (emoji), about 2,800 bytes, with createRow, updateRow or createRows.
  3. Do the same inside a transaction (create operation, commit).

👍 Expected behavior

400 with a clear message (the value cannot be indexed), the same on every write path.

👎 Actual Behavior

Write path Response
createRow 500 general_unknown
updateRow 500 general_unknown
createRows (one of two rows too large) 500 general_unknown, nothing written
transaction create, commit 400 attribute_limit_exceeded "Index row size exceeds the maximum"
createIndex on a column that already holds such a value index failed, "Index row size exceeds the maximum"

Two runs, identical. A B-tree entry in PostgreSQL is limited to about 2,704 bytes. Appwrite accepts key/unique indexes on varchar up to 768 characters, which is up to 3,072 bytes for 4-byte characters, so a valid value in a valid schema can hit the limit. Values with compressible content (the same emoji repeated) stay under it, which makes the failure depend on the data.

Cause: utopia-php/database 7.4.1 maps SQLSTATE 54000 to Limit (Adapter/Postgres.php L2207–L2210). The transaction commit catches it (Transactions/Update.php L363), but the row endpoints do not: Documents/Create.php L486–L496, Documents/Update.php L346–L356; by the code the same applies to Upsert.php, Bulk/Upsert.php and Bulk/Update.php.

🎲 Appwrite version

2.4.0

💻 Operating system

Linux (Debian 12), Docker

🧱 Your Environment

Self-hosted Appwrite 2.4.0, Postgres adapter (appwrite/postgres:0.1.0), two API nodes.

💡 Suggested fix

Catch Utopia\Database\Exception\Limit in the row endpoints and return 400 attribute_limit_exceeded like the commit does. Optionally refuse key/unique indexes on Postgres whose maximum byte length (size × 4) exceeds the B-tree limit, or suggest lengths.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Code of Conduct?

  • I have read the Code of Conduct

Related: #14336 (same catch blocks, NotFound for a missing column returns "table not found").

Activity

  1. added
    product / databases
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / databases

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions