Repository navigation
fix(audits): accept RFC 9562 UUID versions 6-8 in valid_uuid - #6168
Conversation
The valid_uuid audit only allowed version digits 1-5, so well-formed UUIDv6, UUIDv7 and UUIDv8 values (RFC 9562) were reported as invalid. Widen the version digit to 1-8 and update the documented pattern. Signed-off-by: Dhruv Gupta <todhruvg@gmail.com>
mday-io
left a comment
There was a problem hiding this comment.
Thanks for this, the fix and the test look good.
- I ran
test_valid_uuid_auditagainst the oldbuiltin.py: it fails there and passes with the fix. I also broke the pattern two ways (version range[1-7], and dropping the[89ab]variant check), and the test caught both. - I checked the rendered audit on Snowflake, BigQuery, Postgres, T-SQL and Spark. All of them carry the new pattern through correctly.
One correction to the description: this won't show up as a metadata change on the next plan. For built-in audits, _audit_metadata_hash_values in sqlmesh/core/model/definition.py only hashes the audit name and its arguments, not the audit query. I confirmed that a model with valid_uuid(column := a) has the same data and metadata hash before and after this change. So the new pattern takes effect on the next sqlmesh run without a plan, and rows with v6–v8 UUIDs that used to fail the audit will start passing. That's the behavior we want, but could you update that paragraph of the description so the release notes get it right?
Not a blocker, and not something this PR changes: the nil UUID (all zeros) and the max UUID (all fs) still fail the audit, the same as before.
Description
Fixes #6167
The
valid_uuidaudit only allowed version digits1-5, so well-formed UUIDv6, UUIDv7 and UUIDv8 values (RFC 9562) failed the audit. UUIDv7 in particular is now a common key format (uuidv7()in DuckDB and PostgreSQL 18, many application libraries).This widens the version digit in the pattern to
1-8and updates the pattern shown in the audits docs. The variant check ([89ab]) and the rest of the pattern are unchanged.Models that use
valid_uuidwill see the audit change as a metadata change on their next plan, since the built-in audit query changed.Test Plan
test_valid_uuid_auditintests/core/test_audit.py. It checks the rendered query and runs it on DuckDB against the RFC 9562 example UUIDs of versions 1-8 (one upper case), plus values with an unknown version, a non-RFC variant, no hyphens, a non-UUID string and NULL. Only the invalid values are returned. The test fails onmainand passes with this change.pytest tests/core/test_audit.py tests/core/test_model.py tests/core/test_snapshot.py tests/core/test_context.py -n 8 -m "fast and not cicdonly and not isolated": 611 passed.pytest -n auto -m "fast and not cicdonly and not isolated": 2695 passed, 6 skipped, 6 failed. The 6 failures are the pyodbc connection-string tests intests/core/test_connection_config.py, which cannot import pyodbc locally because unixODBC is not installed; they are unrelated to this change.SKIP=prettier,eslint pre-commit run --all-files(ruff, ruff-format, mypy, valid migrations): all passed.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCOSummary by CodeRabbit