litellm - ✅(Solved) Fix [Bug] Batch API - file upload throwing 403 error due to entire s3 object key has been used [1 pull requests, 1 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#23904Fetched 2026-04-08 00:53:56
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2

Error Message

While upload file, I am getting the below 403 error. It seems like entire s3 object key has been used to push files to applogs folder. [92m17:40:13 - LiteLLM:ERROR[0m: s3_v2.py:351 - Error uploading to s3: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/bucket-int/LiteLLMAPPLogs/2026-03-09/time-17-40-11-901585_s3://bucket-int/litellm-bedrock-files-us.anthropic.claude-sonnet-4-5-20250929-v1-0-29ea93-452e-8a2f.jsonl.json'

Fix Action

Fixed

PR fix notes

PR #24061: Updated get_logging_id in utils.py to strip s3://bucket from id. Adde…

Description (problem / solution / changelog)

Updated get_logging_id in utils.py to strip s3://bucket from id. Added tests.

Relevant issues

<!-- e.g. "Fixes #000" -->

Fixes #23904

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🆕 New Feature 🐛 Bug Fix 🧹 Refactoring 📖 Documentation 🚄 Infrastructure ✅ Test

Changes

Changed files

  • litellm/utils.py (modified, +9/-3)
  • tests/test_litellm/integrations/test_s3_v2.py (modified, +65/-0)
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?

As part of batch api validation, I am trying to upload file using “/v1/files” endpoint. Here is the sample curl used to upload file.

 

curl --request POST
    --url https://litellm-int.url/v1/files
    --header 'authorization: Bearer virtualkey'
    --header 'content-type: multipart/form-data'
    --form purpose=batch
    --form 'file=@batch_requests.jsonl'
    --form target_model_names=claude-sonnet-4-5-20250929-batch

 

While upload file, I am getting the below 403 error. It seems like entire s3 object key has been used to push files to applogs folder.

 

[92m17:40:13 - LiteLLM:ERROR[0m: s3_v2.py:351 - Error uploading to s3: Client error '403 Forbidden' for url 'https://s3.amazonaws.com/bucket-int/LiteLLMAPPLogs/2026-03-09/time-17-40-11-901585_s3://bucket-int/litellm-bedrock-files-us.anthropic.claude-sonnet-4-5-20250929-v1-0-29ea93-452e-8a2f.jsonl.json'

claude-sonnet-4-5-20250929-batch from bedrock

model_name: claude-sonnet-4-5-20250929-batch litellm_params: model: bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0 aws_region_name: us-east-1 # Batch-specific parameters for Bedrock Batch API s3_bucket_name: aicoe-litellm-batch-bucket-dev s3_region_name: us-east-1 aws_batch_role_arn: os.environ/BEDROCK_BATCH_ROLE_ARN model_info: mode: batch

Steps to Reproduce

The model being used

claude-sonnet-4-5-20250929-batch from bedrock

model_name: claude-sonnet-4-5-20250929-batch litellm_params: model: bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0 aws_region_name: us-east-1 # Batch-specific parameters for Bedrock Batch API s3_bucket_name: aicoe-litellm-batch-bucket-dev s3_region_name: us-east-1 aws_batch_role_arn: os.environ/BEDROCK_BATCH_ROLE_ARN model_info: mode: batch

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.0

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To resolve the 403 Forbidden error when uploading a file to the /v1/files endpoint, we need to correct the S3 object key construction. The error message indicates that the entire S3 object key is being used incorrectly to push files to the applogs folder.

Here are the concrete steps to fix the issue:

  • Update the S3 object key construction: Ensure that the S3 object key is constructed correctly, without including the entire S3 bucket URL.
  • Verify AWS credentials and permissions: Confirm that the AWS credentials used have the necessary permissions to upload files to the specified S3 bucket.

Example code snippet to construct the S3 object key:

import os

# Define the S3 bucket name and object key prefix
s3_bucket_name = 'aicoe-litellm-batch-bucket-dev'
object_key_prefix = 'LiteLLMAPPLogs/2026-03-09/'

# Construct the S3 object key
object_key = f'{object_key_prefix}{os.path.basename("batch_requests.jsonl")}'

print(object_key)

This code snippet constructs the S3 object key by concatenating the object_key_prefix with the basename of the uploaded file.

Verification

To verify that the fix worked, you can retry the file upload using the corrected S3 object key construction. Monitor the logs for any errors, and confirm that the file is uploaded successfully to the specified S3 bucket.

Extra Tips

  • Ensure that the AWS credentials used have the necessary permissions to upload files to the specified S3 bucket.
  • Verify that the S3 bucket exists and is accessible.
  • Consider implementing additional error handling and logging to diagnose any future issues with file uploads.

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] Batch API - file upload throwing 403 error due to entire s3 object key has been used [1 pull requests, 1 participants]