fix(azure_storage): map the encrypted response id algorithm tag to an ADLS safe file name

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-10-08 04:30:12 +00:00
parent 7925231220
commit 86955f071c
2 changed files with 6 additions and 4 deletions

View file

@ -31,14 +31,14 @@ from litellm.types.secret_managers.get_azure_ad_token_provider import (
from litellm.types.utils import StandardLoggingPayload
AZURE_STORAGE_TOKEN_SCOPE: Final = "https://storage.azure.com/.default"
_ADLS_SAFE_NAME: Final = str.maketrans("/", "_", "=")
_ADLS_SAFE_NAME: Final = str.maketrans("/:", "__", "=")
_DOT_OR_EMPTY_SEGMENTS: Final = frozenset(("", ".", ".."))
def adls_safe_file_name(payload_id: str | None) -> str:
"""A Responses API id is base64 behind `resp_`, and the Data Lake service rejects its `=` padding and `/`, so
that name drops the padding and maps `/` to `_`. Standard base64 has no `_` and its padding is fixed by the
length, so those ids stay distinct. Every other id, including a caller's `x-litellm-call-id`, is used as is
"""A Responses API id is base64 behind `resp_`, with a `v3:gcm:` style algorithm tag when the proxy encrypts it,
and the Data Lake service rejects its `=` padding, `/` and `:`, so that name drops the padding and maps `/` and
`:` to `_`. Standard base64 has no `_` and its padding is fixed by the length, so those ids stay distinct. Every other id, including a caller's `x-litellm-call-id`, is used as is
unless it has an empty, `.` or `..` path segment, which gets the same rewrite so the file keeps its own name in
the log directory"""
name: Final = payload_id or str(uuid.uuid4())

View file

@ -436,6 +436,8 @@ async def test_service_client_is_replaced_at_the_exact_ttl_boundary(mock_env_var
("resp_YWJjZGU=", "resp_YWJjZGU.json"),
("resp_+/8=", "resp_+_8.json"),
("resp_a+b", "resp_a+b.json"),
("resp_v3:gcm:a-b_c==", "resp_v3_gcm_a-b_c.json"),
("resp_v2:gcm:a-b_c=", "resp_v2_gcm_a-b_c.json"),
("chatcmpl-abc123", "chatcmpl-abc123.json"),
),
)