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.
Overview
We use a custom ULID function in our databases, this is a decision that was made prior to lexically sortable uuids natively available in postgres.
The problem is that the shape of a ULID is different from a UUID, the stanza that identifies the version and such has random data in it.
This leads to a problem where some of our UUIDs are randomly assigned values that identifies them as a v4 UUID but others get identified as various other flavours, here's a sample:
Two things all possible ULIDs have in common are:
uuidcolumn successfullyUUID.info()The problem is that in any large enough set of records there'll be some keys that are valid UUIDs according to Sequin and some that are not. I can't make an enrichment function that handles both cases. If I do this:
ULIDs that are parsed as version 4 or 7 function correctly, but all others throw an error like this:
And if I use an enrichment function like this:
all the ULIDs that are "invalid" respond correctly but valid UUIDs return an error like this:
(it complains about several different byte sequences depending on the specific id in question but that makes sense given it's just random bytes).
Solution
In this PR I propose that the UUID check is relaxed down to 'can
UUID.info()parse this at all?'. I am not an Elixir expert so I might not have taken the best approach to get there, but I can confirm that this change consistently returnstruefor all the ULIDs I've thrown at it, while still returningfalsefor nonsense strings.