backend.ai
backend.ai copied to clipboard
Attach unique identifier for low-level error logs
As we target multi-tenancy with appropriately abstracted hardware resources, sometimes exposing too much details about low-level exceptions may impact the security.
Let's create and attach unique identifiers for all exceptions displayed to users so that admins and our support team can search them easily. It would be just enough to use UUID with efficient 22-byte encoding with a prefix like "bai-err-". Let's also attach the relevant request information (the query params and headers) to these exception logs for easier inspection.
link UUID with efficient 22-byte encoding cannot found.
it seems internal repository.
It's just:
>>> from base64 import urlsafe_b64decode, urlsafe_b64encode
>>> import uuid
>>> urlsafe_b64encode(uuid.uuid4().bytes)[0:22]
b'QGPAkw1pQyWsBkUgpNvhng'
>>> uuid.UUID(bytes=urlsafe_b64decode(b'QGPAkw1pQyWsBkUgpNvhng=='))
UUID('4063c093-0d69-4325-ac06-4520a4dbe19e')