Skip to content

Commit c6f0a37

Browse files
authored
fix(core): preserve GUID case in replica map validation (#880)
The _validate_guid function was forcing GUIDs to uppercase, causing FID mismatches in downstream systems (e.g. RootIOHandler) that perform case-sensitive comparisons against the file's original GUID.
1 parent 63d3a01 commit c6f0a37

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

diracx-core/src/diracx/core/models/replica_map.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,19 @@ def _validate_guid(value: str) -> str:
103103
"""Validate GUID checksum format.
104104
105105
The format is 8-4-4-4-12 hexadecimal digits with hyphens (UUID format).
106+
The original case is preserved to avoid mismatches with downstream systems.
106107
Example: 6032CB7C-32DC-EC11-9A66-D85ED3091D71
107108
"""
108-
value = value.upper()
109109
if len(value) != 36:
110110
raise ValueError(
111111
f"GUID checksum must be 36 characters long (including hyphens), got {len(value)}: {value}"
112112
)
113113

114114
# Validate UUID format: 8-4-4-4-12 with hyphens
115115
if not re.match(
116-
r"^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$", value
116+
r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
117+
value,
118+
re.IGNORECASE,
117119
):
118120
raise ValueError(f"GUID checksum must follow format 8-4-4-4-12 (UUID): {value}")
119121

diracx-core/tests/test_replica_map.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ def test_valid_guid_uppercase(self):
112112
)
113113

114114
def test_valid_guid_lowercase(self):
115-
"""Test that valid lowercase GUID is normalized to uppercase."""
115+
"""Test that valid lowercase GUID is preserved as-is."""
116116
assert (
117117
_validate_guid("6032cb7c-32dc-ec11-9a66-d85ed3091d71")
118-
== "6032CB7C-32DC-EC11-9A66-D85ED3091D71"
118+
== "6032cb7c-32dc-ec11-9a66-d85ed3091d71"
119119
)
120120

121121
def test_valid_guid_mixed_case(self):
122-
"""Test that valid mixed case GUID is normalized to uppercase."""
122+
"""Test that valid mixed case GUID is preserved as-is."""
123123
assert (
124124
_validate_guid("6032cb7C-32DC-ec11-9A66-d85eD3091d71")
125-
== "6032CB7C-32DC-EC11-9A66-D85ED3091D71"
125+
== "6032cb7C-32DC-ec11-9A66-d85eD3091d71"
126126
)
127127

128128
def test_guid_wrong_length_raises_error(self):

0 commit comments

Comments
 (0)