BerriAI/litellm · error · ValueError

Cloud storage object name must be relative

Error message

Cloud storage object name must be relative

What it means

Path validation in _validate_cloud_object_path: the object name starts with '/', i.e. an absolute path. Cloud object keys must be relative so a caller cannot escape the managed prefix or address storage roots.

Solutions

  1. Use a relative object name; remove any leading '/' or absolute path.
  2. Do not pass full URLs or absolute paths as the object name.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/cloud_storage_security.py:77 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/f3ec45c29e87cc13. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/cloud_storage_security.py:77

        sanitized_segment = sanitize_cloud_object_component(segment, fallback="")
        if sanitized_segment:
            segments.append(sanitized_segment)

    if not segments:
        return fallback
    return "/".join(segments)


def build_managed_cloud_object_name(prefix: str, filename: str | None, fallback_filename: str = "file") -> str:
    safe_filename: Final = sanitize_cloud_object_component(filename, fallback=fallback_filename)
    return f"{prefix}{uuid.uuid4().hex}-{safe_filename}"


def _validate_cloud_object_path(object_name: str) -> None:
    if not object_name:
        raise ValueError("Cloud storage object name is required")
    if object_name.startswith("/"):
        raise ValueError("Cloud storage object name must be relative")
    if any(ord(char) < 32 or ord(char) == 127 for char in object_name):
        raise ValueError("Cloud storage object name contains control characters")
    segments: Final = object_name.split("/")
    if any(segment in {".", ".."} for segment in segments):
        raise ValueError("Cloud storage object name contains an invalid path segment")
    if "" in segments[:-1]:
        raise ValueError("Cloud storage object name contains an invalid path segment")


def split_configured_cloud_bucket_name(bucket_name: str) -> tuple[str, str]:
    if not isinstance(bucket_name, str) or not bucket_name.strip():
        raise ValueError("Cloud storage bucket name is required")

    bucket_name = bucket_name.strip()
    if "://" in bucket_name or "?" in bucket_name or "#" in bucket_name:
        raise ValueError("Cloud storage bucket name must not include a URI scheme or query")
    if any(ord(char) < 32 or ord(char) == 127 for char in bucket_name):
        raise ValueError("Cloud storage bucket name contains control characters")

View on GitHub (pinned to 77b7c6c40c)