-
Notifications
You must be signed in to change notification settings - Fork 6
fix: validate that UUID field is lower-case #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: validate that UUID field is lower-case #310
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #310 +/- ##
========================================
Coverage 97.40% 97.40%
========================================
Files 87 87
Lines 11952 11954 +2
Branches 1018 608 -410
========================================
+ Hits 11642 11644 +2
Misses 303 303
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Is there a place to document it? The limitation is fine IMO as long as it's documented since it deviates from the spec. |
22ebe3c to
1273467
Compare
Merge activity
|
1273467 to
026dab9
Compare

Why
Technically upper-case UUIDs are valid according to https://datatracker.ietf.org/doc/html/rfc4122.
But the way entity is written expects case sensitivity due to them being treated as simple strings. For example, this would be the expected behavior:
The issue is that Postgres stores them in a case-insensitive manner (which is correct according to the UUID spec). So in actuality, the above code would theoretically do something like:
(it actually fails due to this change of case further up in the stack at
entity/packages/entity/src/EntityDatabaseAdapter.ts
Line 182 in 077d53c
This results in breaking invariants the framework provides (all keys in === all keys out).
This PR solves this problem by just enforcing UUID casing in fields to match what Postgres already does to avoid this issue.
Ref: WWW-37
How
I first tried a field normalization approach in #309, but this also had the same problem: the fields in !== fields out. Unless we were to invert the normalization on the way out, but that comes with a lot of added complexity.
So this is the solution I propose: just don't allow any upper-case characters in the UUIDs. This is technically not UUID spec compliant since we no longer accept all technically valid UUIDs.
Test Plan
Run the test.