From 9275eea1317b27a5e05abe935e2180a95d34c0c5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 2 May 2026 06:13:44 +0000 Subject: [PATCH] Address bugbot: drop dead encode/decode helpers; preserve empty custom_id - Remove unused _encode_gcp_label_value / _decode_gcp_label_value singular helpers; only the _chunks variants are actually called. - Use 'is not None' check for custom_id so empty-string custom_ids are still labeled and round-trip through batch outputs. Co-authored-by: Mateo Wang --- litellm/llms/vertex_ai/files/transformation.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/litellm/llms/vertex_ai/files/transformation.py b/litellm/llms/vertex_ai/files/transformation.py index ea4f498283f..0f07b24cc08 100644 --- a/litellm/llms/vertex_ai/files/transformation.py +++ b/litellm/llms/vertex_ai/files/transformation.py @@ -63,17 +63,6 @@ def _sanitize_gcp_label_value(value: str) -> str: return sanitized[:_GCP_LABEL_VALUE_MAX_LEN] -def _encode_gcp_label_value(value: str) -> str: - """Encode arbitrary text into a GCP-label-safe value.""" - max_encoded_len = _GCP_LABEL_VALUE_MAX_LEN - len(_CUSTOM_ID_RAW_LABEL_PREFIX) - encoded = ( - base64.b32encode(value.encode("utf-8")).decode("ascii").rstrip("=").lower() - ) - if len(encoded) > max_encoded_len: - raise ValueError("Encoded label value exceeds GCP label length") - return f"{_CUSTOM_ID_RAW_LABEL_PREFIX}{encoded}" - - def _encode_gcp_label_value_chunks(value: str) -> List[str]: """Encode arbitrary text across one or more GCP-label-safe values.""" max_encoded_len = _GCP_LABEL_VALUE_MAX_LEN - len(_CUSTOM_ID_RAW_LABEL_PREFIX) @@ -86,11 +75,6 @@ def _encode_gcp_label_value_chunks(value: str) -> List[str]: ] or [_CUSTOM_ID_RAW_LABEL_PREFIX] -def _decode_gcp_label_value(value: str) -> Optional[str]: - """Decode values produced by _encode_gcp_label_value.""" - return _decode_gcp_label_value_chunks([value]) - - def _decode_gcp_label_value_chunks(values: List[str]) -> Optional[str]: """Decode values produced by _encode_gcp_label_value_chunks.""" encoded_parts = [] @@ -170,7 +154,7 @@ def _openai_batch_jsonl_entries_to_vertex_wrapped_requests( # Add custom_id as a label for correlation in batch outputs custom_id = _openai_jsonl_content.get("custom_id") - if custom_id: + if custom_id is not None: if "labels" not in vertex_request_body: vertex_request_body["labels"] = {} _set_litellm_batch_custom_id_labels(