Repository navigation
Description
π Reproduction steps
- Table with existing rows (here 5 million), add an optional varchar column
c(all rows haveNULL). PATCH /v1/tablesdb/{db}/tables/{table}/columns/varchar/cwith{"required": true, "default": null}β200, columnavailable.- Update any existing row without touching
c, e.g.PATCH β¦/rows/{rowId}with{"data": {"other": 1}}.
π Expected behavior
Either the change is rejected while rows without a value exist (or a default is required for them), or existing rows stay updatable.
π Actual Behavior
The change is accepted, and from then on every partial update of every existing row fails:
400 Invalid document structure: Missing required attribute "c"
With 4 clients updating random rows of the table, all 120 updates in the next seconds failed with this error; a single updateRow that only changes another column also fails. Reads still work. In practice one click in the console ("required") blocks all writes to the table until the column is made optional again or every row has been backfilled β and a backfill via updateRows is not possible on tables with relationships.
updateAttribute() sets the flag without checking existing values (Collections/Attributes/Action.php L496βL550), while the structure validator on update checks the merged document, which contains c = null for old rows.
π² Appwrite version
2.3.0
π» Operating system
Linux (Debian 12), Docker
π§± Your Environment
Self-hosted Appwrite 2.3.0, Postgres adapter (PostgreSQL 18).
π‘ Suggested fix
Reject required: true when rows with NULL exist (a cheap EXISTS β¦ IS NULL check), or require a default that is written to existing rows, or skip the required check for attributes not present in a partial update.
π 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
Activity
fix(databases): allow updates of rows that predate a required column