From 70aa52dca3a40efe88e165d3294d20a1add4e5b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5nis=20Ormisson?= Date: Sun, 22 Nov 2026 00:17:45 +0200 Subject: [PATCH] Generate RFC 4122 version 4 catalog ids (0.8.3) --- CHANGELOG.md | 12 ++++++++++++ src/Sql/NormativeCatalog.php | 6 +++++- tests/Sql/NormativeCatalogUuidTest.php | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Sql/NormativeCatalogUuidTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 648ffd0..ffe3c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## [Unreleased] +## [0.8.3] - 2026-11-22 + +### Fixed + +- Catalog identifiers are now RFC 4122 version 4 UUIDs. Before, they were 16 + random bytes without version or variant bits, so about five of eight imported + datasets got an id that `InPlaceApplyRequest` rejects with + `invalid_dataset_id`, and in-place transformations could not be applied to + them. Datasets imported by earlier versions keep their ids; re-import one + whose id is rejected. Found by a three-way benchmark with Statscraft and the + Python adapter. + ## [0.8.2] - 2026-11-09 ### Changed diff --git a/src/Sql/NormativeCatalog.php b/src/Sql/NormativeCatalog.php index c5d5544..48f69fb 100644 --- a/src/Sql/NormativeCatalog.php +++ b/src/Sql/NormativeCatalog.php @@ -670,7 +670,11 @@ public static function timestamp(): string public static function uuid(): string { - $hex = bin2hex(random_bytes(16)); + // RFC 4122 version 4: the in-place executor accepts only the 8/9/a/b variant. + $bytes = random_bytes(16); + $bytes[6] = chr((ord($bytes[6]) & 0x0f) | 0x40); + $bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80); + $hex = bin2hex($bytes); return substr($hex, 0, 8) . '-' . substr($hex, 8, 4) . '-' . substr($hex, 12, 4) . '-' . substr($hex, 16, 4) . '-' . substr($hex, 20); } } diff --git a/tests/Sql/NormativeCatalogUuidTest.php b/tests/Sql/NormativeCatalogUuidTest.php new file mode 100644 index 0000000..0606360 --- /dev/null +++ b/tests/Sql/NormativeCatalogUuidTest.php @@ -0,0 +1,21 @@ +