litellm - ✅(Solved) Fix [Bug]: S3 filename too long [2 pull requests, 2 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#24628Fetched 2026-04-08 01:37:31
View on GitHub
Comments
2
Participants
2
Timeline
10
Reactions
0
Author
Timeline (top)
cross-referenced ×4commented ×2labeled ×2referenced ×2

Error Message

12:51:34 - LiteLLM:ERROR: s3_v2.py:380 - Error uploading to s3: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'

For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Traceback (most recent call last):

File "/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py", line 375, in async_upload_data_to_s3

response = await self.async_httpx_client.put(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    url, data=json_string, headers=signed_headers

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

)

^

File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 579, in put

raise e

File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 541, in put

response.raise_for_status()

~~~~~~~~~~~~~~~~~~~~~~~~~^^

File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status

raise HTTPStatusError(message, request=request, response=self)

httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'

Fix Action

Fixed

PR fix notes

PR #24637: Fix overlong S3 logging object keys

Description (problem / solution / changelog)

Fixes #24628.

Summary

  • cap the final S3 filename component to a filesystem-safe length inside get_s3_object_key
  • preserve the readable time/id prefix while appending a deterministic hash suffix for overlong keys
  • add regression coverage for direct key generation and S3Logger.create_s3_batch_logging_element() with very long response ids
  • update the shared asyncio.create_task test fixture in test_s3_v2.py so discarded mocked coroutines are closed cleanly during these S3 logger tests

Validation

  • python -m poetry run pytest tests/test_litellm/integrations/test_s3_v2.py -k "truncates_long_filename_components or limits_long_ids or combined_prefix_reflects_in_s3_object_key" -vv
  • python -m poetry run black --check litellm/integrations/s3.py tests/test_litellm/integrations/test_s3_v2.py

Changed files

  • litellm/integrations/s3.py (modified, +8/-0)
  • tests/test_litellm/integrations/test_s3_v2.py (modified, +215/-88)

PR #24642: fix: truncate long response IDs in get_logging_id to prevent S3 filename too long errors (#24628)

Description (problem / solution / changelog)

Fixes #24628. When responses contain extremely long IDs, the generated S3 object key exceeds the 255-character filename limit enforced by OS/local S3 implementations like MinIO or rustfs, causing a 500 Internal Server Error. This PR truncates the raw response ID to a maximum of 150 characters within get_logging_id to ensure safe, cross-platform filesystem limits.\n\n*(Refactored using the open-source 0-editor)*

Changed files

  • litellm/utils.py (modified, +1/-1)

Code Example

12:51:34 - LiteLLM:ERROR: s3_v2.py:380 - Error uploading to s3: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'

For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Traceback (most recent call last):

  File "/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py", line 375, in async_upload_data_to_s3

    response = await self.async_httpx_client.put(

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        url, data=json_string, headers=signed_headers

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    )

    ^

  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 579, in put

    raise e

  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 541, in put

    response.raise_for_status()

    ~~~~~~~~~~~~~~~~~~~~~~~~~^^

  File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status

    raise HTTPStatusError(message, request=request, response=self)

httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'
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?

When try to store logs on my dokerized S3 compatible rustfs image I get an 500 error. Trying to create manually a file with that long filename outputs a filename too long. Windows or Ubuntu has 255 limit character for filenames Can make the filename shorter?

Steps to Reproduce

  1. Add a dockerized S3 Compatible on Windows or linux host
  2. Try to save logs in that S3

Relevant log output

12:51:34 - LiteLLM:ERROR: s3_v2.py:380 - Error uploading to s3: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'

For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Traceback (most recent call last):

  File "/usr/lib/python3.13/site-packages/litellm/integrations/s3_v2.py", line 375, in async_upload_data_to_s3

    response = await self.async_httpx_client.put(

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        url, data=json_string, headers=signed_headers

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    )

    ^

  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 579, in put

    raise e

  File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 541, in put

    response.raise_for_status()

    ~~~~~~~~~~~~~~~~~~~~~~~~~^^

  File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status

    raise HTTPStatusError(message, request=request, response=self)

httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'http://rustfs:9000/litellm/2026-03-26/time-12-51-27-995047_resp_MDcGKOrxhcDkVhHHxwmHy3c1QwQeNNE9MKpL3q7DvZ2zzW4uoHxSmJJkO-cjky3Cn__D5a2hKxJcET1c7PGRCIdj4SiYChyo1_kIVV21WqNJw_ucofO9M69PfNKW76c8dLzqRRXfKtdJUN6sEPpyS9lXCo--yRfixLUvk3BUG4aBEFRi7HR6jJcOnyjvo_O62jj2f83JHSAJcm2-d3ll8_IiYgydQ75gAditcJwIygXyKQFevn7rTbzRhKJnTFP7Cj7NFdMLY2HLSH3iWWTEECefGalUR2DPt0ddKtCyZqTFIR9XXRWmfv4P9Iq0HOt70VnSuQ_7hmmeVvt3FFTJ44EEkRJbwiyCf1YcaP4f7YoY9muWYWfxqhoWVycrawu9MxWMkRIUZ9sgaf513F0nntxCQU1SretKtUOvLIkc.json'

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To resolve the issue of filename being too long, we can shorten the filename by using a hash of the original filename or by truncating it to a certain length.

Here are the steps:

  • Modify the async_upload_data_to_s3 function in s3_v2.py to shorten the filename before uploading it to S3.
  • Use a library like hashlib to generate a hash of the original filename and use it as the new filename.
  • Alternatively, truncate the filename to a certain length (e.g., 255 characters) to ensure it is within the allowed limit.

Example code:

import hashlib

# ...

def async_upload_data_to_s3(self, data):
    # Generate a hash of the original filename
    original_filename = "long_filename.json"
    hashed_filename = hashlib.sha256(original_filename.encode()).hexdigest()[:255] + ".json"
    
    # Alternatively, truncate the filename to a certain length
    # truncated_filename = original_filename[:255] + ".json"
    
    # Use the shortened filename for uploading to S3
    url = f"http://rustfs:9000/litellm/{hashed_filename}"
    response = await self.async_httpx_client.put(url, data=json_string, headers=signed_headers)
    # ...

Verification

To verify that the fix worked, try uploading a file with a long filename to S3 using the modified async_upload_data_to_s3 function. If the upload is successful, it should indicate that the filename shortening fix is working correctly.

Extra Tips

  • Make sure to handle any potential collisions when using a hash of the original filename.
  • Consider using a more robust hashing algorithm like sha256 to minimize the risk of collisions.
  • If truncating the filename, ensure that the truncated filename is still unique and does not overwrite any existing files.

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