litellm - ✅(Solved) Fix [Bug]: S3 team alias prefix with space in team name [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25019Fetched 2026-04-08 02:35:04
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2commented ×1mentioned ×1

Error Message

{"message": "Error uploading to s3: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/<bucket>/<path>/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403", "level": "ERROR", "timestamp": "2026-03-31T17:52:59.582760", "stacktrace": "Traceback (most recent call last):\n File "/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py", line 375, in async_upload_data_to_s3\n response = await self.async_httpx_client.put(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n url, data=json_string, headers=signed_headers\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 579, in put\n raise e\n File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 541, in put\n response.raise_for_status()\n ~~~~~~~~~~~~~~~~~~~~~~~~~^^\n File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status\n raise HTTPStatusError(message, request=request, response=self)\nhttpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/llm-gateway-dev-logs/dev/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403"}

PR fix notes

PR #25068: fix(s3): sanitize spaces in team_alias prefix to prevent 403 errors

Description (problem / solution / changelog)

Summary

Fixes #25019.

When s3_use_team_prefix is enabled and a team name contains spaces (e.g. "Cloud Tooling"), the S3 object key includes the raw space character. The HTTP client URL-encodes this to %20, but AWS SigV4 signs the request using the raw key path — causing a signing mismatch and a 403 Forbidden response.

Root Cause

_create_s3_batch_logging_element() builds the S3 key prefix from user_api_key_team_alias without sanitizing special characters. When team_alias = "Cloud Tooling", the resulting key is:

dev/Cloud Tooling/ugie-dev/2026-03-31/...

httpx URL-encodes the space to %20 in the request URL, but SigV4 canonical URI uses the raw path — mismatch → 403.

Fix

After joining prefix components, replace whitespace characters (spaces, tabs, newlines) with underscores using re.sub(r"[\\s]+", "_", prefix_path). This produces clean S3 keys like:

dev/Cloud_Tooling/ugie-dev/2026-03-31/...

Multiple consecutive whitespace characters collapse to a single underscore.

Changes

  • litellm/integrations/s3_v2.py: Added import re and whitespace sanitization after prefix path construction
  • tests/logging_callback_tests/test_s3_space_sanitize.py: 4 new tests covering spaces, multiple spaces, no-space passthrough, and tabs

Testing

pytest tests/logging_callback_tests/test_s3_space_sanitize.py -v

Changed files

  • litellm/integrations/s3_v2.py (modified, +4/-1)
  • tests/logging_callback_tests/test_s3_space_sanitize.py (added, +44/-0)

PR #25074: fix(s3_v2): use prepared URL for SigV4-signed S3 requests

Description (problem / solution / changelog)

fixes #25019

Summary

  • SigV4 was computed on requests’ prepared URL (%20 for spaces) while httpx used the raw URL (literal spaces), causing signature mismatch and 403 on PUT/GET.
  • Use prepped.url for httpx so the request matches the signed URL.

Changes

  • litellm/integrations/s3_v2.py: async upload, sync upload, and download now call httpx with prepped.url.
  • tests/test_litellm/integrations/test_s3_v2.py: test for object keys with spaces (e.g. team name in prefix).

Type

  • Bug fix

Changed files

  • litellm/integrations/s3_v2.py (modified, +7/-6)
  • tests/test_litellm/integrations/test_s3_v2.py (modified, +44/-0)

Code Example

{"message": "Error uploading to s3: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/<bucket>/<path>/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403", "level": "ERROR", "timestamp": "2026-03-31T17:52:59.582760", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py\", line 375, in async_upload_data_to_s3\n    response = await self.async_httpx_client.put(\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        url, data=json_string, headers=signed_headers\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 579, in put\n    raise e\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 541, in put\n    response.raise_for_status()\n    ~~~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_models.py\", line 829, in raise_for_status\n    raise HTTPStatusError(message, request=request, response=self)\nhttpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/llm-gateway-dev-logs/dev/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403"}
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

With S3 logging and team alias prefix enabled, a space in the team name causes the S3 upload to error with a 403.

Steps to Reproduce

  1. Create a team with space in the name
  2. Enable S3 logging with team alias prefix
  3. Make a call for chat completions

Relevant log output

{"message": "Error uploading to s3: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/<bucket>/<path>/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403", "level": "ERROR", "timestamp": "2026-03-31T17:52:59.582760", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py\", line 375, in async_upload_data_to_s3\n    response = await self.async_httpx_client.put(\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        url, data=json_string, headers=signed_headers\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 579, in put\n    raise e\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 541, in put\n    response.raise_for_status()\n    ~~~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_models.py\", line 829, in raise_for_status\n    raise HTTPStatusError(message, request=request, response=self)\nhttpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/llm-gateway-dev-logs/dev/Cloud%20Tooling/ugie-dev/2026-03-31/time-17-52-52-187284_chatcmpl-a642e753-bda8-482a-89b3-d63b8c449daa.json'\nFor more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403"}

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

extent analysis

TL;DR

The 403 error when uploading to S3 with a team name containing a space may be resolved by properly encoding or handling the space in the team alias prefix.

Guidance

  • Verify that the issue is indeed caused by the space in the team name by testing with a team name without spaces.
  • Check the documentation for S3 logging and team alias prefix to ensure that spaces are allowed and properly handled.
  • Consider encoding the team name or using a different character in place of the space to avoid potential issues with URL encoding.
  • Review the S3 bucket policy to ensure that it allows uploads from the LiteLLM proxy with the specified team alias prefix.

Example

No code snippet is provided as the issue does not imply a specific code change.

Notes

The root cause of the issue is likely related to the handling of spaces in the team alias prefix, but without further information, it is difficult to provide a definitive solution.

Recommendation

Apply a workaround, such as encoding the team name or using a different character in place of the space, as the issue is likely related to the handling of special characters in the team alias prefix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: S3 team alias prefix with space in team name [2 pull requests, 1 comments, 2 participants]