Skip to content

fix: keep documents with a null required attribute updatable - #1000

Merged
HarshMN2345 merged 1 commit into
mainfrom
fix/required-attribute-stored-null
Oct 7, 2026
Merged

HarshMN2345 merged 1 commit into
mainfrom
fix/required-attribute-stored-null

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

An attribute that becomes required after documents exist leaves those documents holding null for it. That happens when an optional attribute is made required, or when a required attribute is added to a populated collection. updateDocument() and upserts validate the merged document, so every update of such a document failed with Missing required attribute, including updates that never touch the attribute.

Structure already receives the stored document as currentDocument. When it holds null for a required attribute, the required check and the null value check now let the attribute stay null. Setting a value still works. Clearing a stored value, and creating a document without the attribute, still fail. Bulk updateDocuments() is unchanged, since PartialStructure only checks required attributes present in the update.

Verified on Appwrite (Postgres) with the patched validator: a partial update and an upsert of an old row now return 200 instead of 400. Clearing a set value and creating a row without the column still return 400.

Refs appwrite/appwrite#14175

A document stored before an attribute became required holds null for it,
and updates validate the merged document, so every update of that
document failed with "Missing required attribute". When the current
document already holds null, the attribute may stay null on update.
Creating a document without it, or clearing a stored value, still fails.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: utopia-php/database/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 344564a1-b8f8-44bd-98b2-d951bab580b0
📥 Commits

Reviewing files that changed from the base of the PR and between ef5d6e5 and 074e562.

📒 Files selected for processing (2)
  • src/Database/Validator/Structure.php
  • tests/unit/Validator/StructureTest.php
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@HarshMN2345
HarshMN2345 merged commit 7dc5546 into main Oct 7, 2026
21 checks passed
@HarshMN2345
HarshMN2345 deleted the fix/required-attribute-stored-null branch October 7, 2026 10: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.

2 participants