Repository navigation
fix(databases): restore the column type guard on attribute updates - #13536
Merged
Merged
Conversation
Both type checks in updateAttribute() closed their parentheses one token early,
so the comparison was evaluated as the argument:
$attribute->getAttribute(('type') !== $type)
That passes a bool where a key is expected. Without strict_types PHP coerces it
to '1' or '', neither of which is a key on the attribute, so getAttribute()
returned null and the guard never fired - on any of the update endpoints that
funnel through this base.
The result was that updating a column through the wrong type's endpoint, or
changing the filter of a string column, skipped validation instead of returning
column_type_invalid, and handed a mistyped default to the database adapter.
Contributor
Greptile SummaryRestores attribute update validation so requests must use both the correct column type and, for strings, the correct persisted format.
Confidence Score: 5/5The PR appears safe to merge; the current guards match attribute persistence and the resolved previous findings are covered by the expanded tests. No new actionable failures remain. Both previous threads are resolved, and the current code fixes the incorrect field comparison while adding direct coverage for the type and format paths. Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/column-type..." | Re-trigger Greptile |
Restoring the parentheses alone made the second guard read 'filter', which is never stored on an attribute - the create path persists the discriminator as 'format', empty for a plain string. Every email, URL, IP and enum update would have been rejected. Compare against 'format', treating the plain string endpoint's absent filter as the empty string it is stored as, and cover both directions in the test.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
ArnabChatterjee20k
approved these changes
Sep 8, 2026
2 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #12969
What does this PR do?
Both type checks in the shared attribute/column update base closed their parentheses one token early:
That passes the comparison as the argument.
getAttribute()takes astring, the file has nodeclare(strict_types=1), so PHP coerces the bool to'1'or''— neither is a key on the attribute,getAttribute()returns itsnulldefault, andif (null)is never true:So the guard that rejects "update this column as a boolean when it is really a string" never fired, on any of the update endpoints that funnel through this base. Instead of a clean 400
column_type_invalid/attribute_type_invalid, the request proceeded and handed a mistyped default down toDatabase::updateAttribute(). The same slip is in the adjacent string-filter check.Relationship to #12969
I could not reproduce the reported
xdefault: false→NULLas a falsy-drop bug, and I traced every hop looking for one: the param is bound witharray_key_existsrather than truthiness,Nullable(Boolean)acceptsfalse, both guards in the create path already useisset()(the 2022 fix in d45464c still stands), thecastingfilter round-tripsfalse/0/0.0/""losslessly, and the worker guards on!== null. Same result for every column type on both the/v1/databasesand/v1/tablesdbsurfaces.What is real in that report is that adding a column never backfills rows that already exist — the physical column is created without a SQL default and reads do not apply one. That is identical for
trueandfalse, so it is not a boolean bug, and it is a product decision (backfilling is expensive on large tables) rather than something to fix here.This PR ships the one genuine defect the investigation did turn up in that code path.
Test Plan
tests/e2e/Services/Databases/DatabasesBase::testUpdateAttributeRejectsMismatchedTypecreates a string column and updates it through the boolean endpoint, expecting 400 and the surface's own error type. It lives in the shared base, so it runs for the legacy, DocumentsDB and TablesDB suites.