Skip to content

fix(databases): allow updates of rows that predate a required column - #14202

Merged
HarshMN2345 merged 7 commits into
mainfrom
cursor/required-column-partial-update-6f42
Oct 7, 2026
Merged

HarshMN2345 merged 7 commits into
mainfrom
cursor/required-column-partial-update-6f42

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes #14175. A row stored before a column became required holds null for it. That happens when a column is made required, or when a required column is added to a table that already has rows. Row updates and upserts validate the merged row, so every update of such a row failed with Missing required attribute, even when the update never touched the column.

The fix is in the Structure validator of utopia-php/database (utopia-php/database#1000, released in 7.4.1), and this PR bumps the dependency to ^7.4.1. A required column that the stored row already holds as null may stay null. Setting it still works. Clearing a set value, and creating a row without it, still fail.

Test Plan

testUpdateRequiredAttributeAllowsPartialUpdate (TablesDB and legacy Databases) creates rows and makes an empty column required. It then checks that updating or upserting another column returns 200 and leaves the column null, that setting the column returns 200, and that clearing the column or creating a row without it returns 400.

Run locally against an API container with the patched validator, both TablesDBCustomServerTest and LegacyCustomServerTest pass. With the current validator the test fails at the partial update, which returns 400.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Making a column required left older rows null. Single-row updates merge
that null into the document and then reject it as a missing attribute,
so every partial update failed. An unchanged null is validated as
optional. Creates, and updates that clear a value already set, still fail.

Fixes #14175
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • 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 7, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/required-column-partial-update-6f42 (after).

Metric Before After Change
🚀 Requests/sec 193.36 208.9 🟢 +8%
⏱️ Latency P50 88.42 ms 82.48 ms 🟢 -6.7%
⏱️ Latency P95 212 ms 192.28 ms 🟢 -9.3%
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 82.48 192.28 13,281 208.9 -19.72
Account 158.02 277.27 699 11.6 -40.63
TablesDB 77.5 144.86 7,223 116.92 -34.47
Storage 79.02 170.91 3,495 57.83 -2.6
Functions 120.28 233.35 1,864 31.42 -4.21

Top API waits (after)

API request Max wait (ms)
account.name.update 424.79
functions.variables.update 383.46
functions.create 379.21
account.prefs.update 371.13
storage.buckets.create 343.96

HarshMN2345 and others added 4 commits October 7, 2026 14:51
Remove the renamed copy of utopia-php/database's Structure validator, the
subclass that shadowed it through the autoloader, the classmap, Pint and
PHPStan exclusions it needed, and its hash-locked unit test. The
required-null check belongs in the library's Structure validator.
Assert a partial update and an upsert of a row that predates a required
column succeed and leave that column null.

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost

ghost commented Oct 7, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The dependency and lockfile now include the required release, and no remaining defects were identified in the reviewed changes.

The PR upgrades utopia-php/database to 7.4.1 to allow updates of existing rows whose required column is already null. It adds shared API regression coverage for partial updates, upserts, filling the column, and rejection of missing or cleared required values.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 3
File Change
composer.json Raises the minimum database dependency version to 7.4.1.
composer.lock Locks utopia-php/database to the 7.4.1 release.
tests/e2e/Services/Databases/DatabasesBase.php Adds shared regression coverage for rows with a column made required after creation.
✅ Fixed since the last review · 1
  • Include the validator dependency update before merging · tests/e2e/Services/Databases/DatabasesBase.php:1742

Reviewed 1b47448 · 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 B · 1 blocking finding to address. Summary

@HarshMN2345
HarshMN2345 marked this pull request as ready for review October 7, 2026 13:22
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR bumps the utopia-php/database dependency from ^7.4.0 to ^7.4.1 (consistent with composer.lock) and adds a new e2e test covering required-attribute semantics with partial updates.

Files Change
composer.json Patch-bumps utopia-php/database to ^7.4.1, matching the pinned composer.lock.
tests/e2e/Services/Databases/DatabasesBase.php Adds testUpdateRequiredAttributeAllowsPartialUpdate exercising required-attribute behavior across PATCH partial updates, PUT upserts, and create-time validation across database adapters.

Reviewed commit: 1b47448

@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

@HarshMN2345
HarshMN2345 merged commit 6562e63 into main Oct 7, 2026
416 of 419 checks passed
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.

🐛 Bug Report: Making a column required blocks updates of old rows

1 participant