Skip to content

Conversation

@wschurman
Copy link
Member

@wschurman wschurman commented Sep 30, 2025

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:

const entities = await TestEntity.loader(vc).loadManyByFieldEqualingAsync('id', ['018EBFDA-DC80-782D-A891-22A0AA057D52']);
=> Map(['018EBFDA-DC80-782D-A891-22A0AA057D52', TestEntity[...]])

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:

const entities = await TestEntity.loader(vc).loadManyByFieldEqualingAsync('id', ['018EBFDA-DC80-782D-A891-22A0AA057D52']);
=> Map(['018ebfda-dc80-782d-a891-22a0aa057d52', TestEntity[...]])

(it actually fails due to this change of case further up in the stack at

`Unexpected object field value during database result transformation: ${objectMapKeyForObject}. This should never happen.`,
, but the reason is the same: postgres transforms to lower case under-the-hood)

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.

Copy link
Member Author

wschurman commented Sep 30, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.40%. Comparing base (02f92fc) to head (026dab9).
⚠️ Report is 1 commits behind head on main.

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            
Flag Coverage Δ
integration 6.09% <0.00%> (-0.01%) ⬇️
unittest 94.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wschurman wschurman requested review from ide and quinlanj September 30, 2025 17:27
@wschurman wschurman marked this pull request as ready for review September 30, 2025 17:27
@ide
Copy link
Member

ide commented Sep 30, 2025

Is there a place to document it? The limitation is fine IMO as long as it's documented since it deviates from the spec.

@wschurman wschurman force-pushed the wschurman/09-30-fix_validate_that_uuid_field_is_lower-case branch from 22ebe3c to 1273467 Compare September 30, 2025 19:40
Copy link
Member Author

wschurman commented Sep 30, 2025

Merge activity

  • Sep 30, 7:48 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 30, 7:50 PM UTC: Graphite rebased this pull request as part of a merge.
  • Sep 30, 7:52 PM UTC: @wschurman merged this pull request with Graphite.

@wschurman wschurman changed the base branch from wschurman/09-29-chore_fix_erroneous_describe.only_and_add_lint_rule_to_prevent_it to graphite-base/310 September 30, 2025 19:48
@wschurman wschurman changed the base branch from graphite-base/310 to main September 30, 2025 19:49
@wschurman wschurman force-pushed the wschurman/09-30-fix_validate_that_uuid_field_is_lower-case branch from 1273467 to 026dab9 Compare September 30, 2025 19:49
@wschurman wschurman merged commit 949f00d into main Sep 30, 2025
4 checks passed
@wschurman wschurman deleted the wschurman/09-30-fix_validate_that_uuid_field_is_lower-case branch September 30, 2025 19:52
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.

4 participants