snok / asgi-correlation-id

Request ID propagation for ASGI apps
MIT License
369 stars 29 forks source link

Default inbound correlation-id validator is incorrect? #89

Open dmder opened 1 month ago

dmder commented 1 month ago
from asgi_correlation_id.middleware import is_valid_uuid4

# returns True but I expected it to return False since 
# '00000000000000000000000000000000' is not a valid version 4 UUID
is_valid_uuid4(uuid.UUID(int=0).hex)  

This is because uuid.UUID('00000000000000000000000000000000', version=4) returns UUID('00000000-0000-4000-8000-000000000000').

I suspect this should rather be something like UUID(uuid_).version == 4

sondrelg commented 1 month ago

Hmm, yes that seems right @dmder. Would you be interested in creating a PR with the fix?