Skip to content

Commit ba5fefe

Browse files
author
Max Wang
committed
enforce optional correlation id input to be guid
1 parent a507b78 commit ba5fefe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,14 @@ def __init__(
156156
def _call_scope(self, correlation_id: Optional[str] = None):
157157
"""Context manager to share a correlation id across nested SDK calls."""
158158
existing = _CALL_SCOPE_CORRELATION_ID.get()
159-
shared_id = correlation_id or existing or str(uuid.uuid4())
159+
if correlation_id is not None:
160+
if not (_GUID_RE.fullmatch(correlation_id)):
161+
raise ValueError("correlation_id provided must be a GUID string")
162+
shared_id = correlation_id
163+
elif existing is not None:
164+
shared_id = existing
165+
else:
166+
shared_id = str(uuid.uuid4())
160167
token = _CALL_SCOPE_CORRELATION_ID.set(shared_id)
161168
try:
162169
yield shared_id

0 commit comments

Comments
 (0)