Skip to content

fix(bedrock)!: use the S3 bucket passed to SDK file calls instead of requiring proxy config - #47601

Merged
ryan-crabbe-berri merged 6 commits into
litellm_proxy_client_storage_allowlistfrom
litellm_bedrock_files_trust_call_bucket
Nov 6, 2026
Merged

ryan-crabbe-berri merged 6 commits into
litellm_proxy_client_storage_allowlistfrom
litellm_bedrock_files_trust_call_bucket

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Python SDK users who upload a Bedrock batch file to their own S3 bucket can't read, list or delete it after, because the SDK only trusted a bucket the proxy handed it. This PR makes the SDK use the bucket passed on the call, or the env var. It is only safe on top of #47496, so that one merges first

Breaking change: a per-model allow_legacy_cloud_file_ids in the proxy config now takes effect where it was silently ignored before, and the missing-bucket error text changed, so admins who set that flag and anyone matching the old error text should check both before upgrading

Details

TLDR

Problem this solves:

  • SDK users upload a file to Bedrock with their bucket name
  • Reading that file back fails, saying no bucket was given

How it solves it:

Intentional product change: the SDK now honors the bucket and legacy-flag params passed on the call, the proxy's per-model allow_legacy_cloud_file_ids takes effect, and model-routed Bedrock batches go through the batch rate limiter. All three were skipped before

User Flow

Before: an SDK user can upload a batch file to their S3 bucket but can never read it back

  1. litellm.create_file(..., custom_llm_provider="bedrock", s3_bucket_name="my-bucket") returns an s3://my-bucket/... id
  2. litellm.file_content(file_id=<that id>, custom_llm_provider="bedrock", s3_bucket_name="my-bucket") raises S3 bucket_name is required even though they passed it

After: the same read returns the file, and a file in another bucket is still refused

  1. The same create_file returns an s3://my-bucket/... id
  2. The same file_content returns the file's lines
  3. file_content for s3://some-other-bucket/... while passing my-bucket raises file_id bucket does not match the configured storage bucket

Relevant issues

Fixes #45061

Stacked on #47496, which has to merge first. Replaces #47459

Linear ticket

Resolves LIT-9501

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings 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).

Screenshots / Proof of Fix

Setup. Real Bedrock batch in us-east-1 on litellm-lit7720-batch-qa-888 with Haiku 4.5, since Haiku 5.5 has no Bedrock batch here. SDK cases are one script, python sdk_cases.py (below), run from each tree's .venv with AWS keys set and AWS_S3_BUCKET_NAME unset. It echoes each call as a >>> line and prints an exception as its type and first line. Proxy cases are curl against --num_workers 2, fresh databases and #47496's config. Before is #47496's tip

Case Before (9d972c8) After (b03cbd7)
1. SDK reads back its upload ValueError file returned
2. SDK, file in another bucket ValueError refused
3. SDK, list files ValueError upload listed
4. SDK, output bucket only ValueError file returned
5. SDK, legacy id, no flag ValueError refused
6. SDK, legacy id, flag on ValueError file returned
7. SDK, delete ValueError deleted
P1. Proxy upload and read 200 200
P2. Proxy retrieve 200 200
P3. Proxy list 200, listed 200, listed
P4. Proxy delete 200 200
P5. Proxy managed batch 200 200
sdk_cases.py
import sys
import litellm

hexs = open("hex.txt").read().strip()
bucket = "litellm-lit7720-batch-qa-888"
other_bucket = f"litellm-qa-client-bucket-{hexs}"
aws = {"custom_llm_provider": "bedrock", "aws_region_name": "us-east-1"}


def show(label, call, fn):
    print(f"### {label}\n>>> {call}")
    try:
        result = fn()
        print(result)
    except Exception as e:
        print(f"{type(e).__name__}: {str(e).splitlines()[0][:300]}")
    print()


created = litellm.create_file(file=open("sdk_batch.jsonl", "rb"), purpose="batch", s3_bucket_name=bucket, **aws)
print(f">>> litellm.create_file(file=open('sdk_batch.jsonl', 'rb'), purpose='batch', custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1').id\n{created.id}\n")

show("1. read back the file it uploaded",
     f"litellm.file_content(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1').text",
     lambda: litellm.file_content(file_id=created.id, s3_bucket_name=bucket, **aws).text.strip())
show("2. ask for a file in a different bucket",
     f"litellm.file_content(file_id='s3://{other_bucket}/litellm-bedrock-files/x.jsonl', custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1')",
     lambda: litellm.file_content(file_id=f"s3://{other_bucket}/litellm-bedrock-files/x.jsonl", s3_bucket_name=bucket, **aws).text)
show("3. list files",
     f"litellm.file_list(custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1')",
     lambda: (lambda files: f"{len(files)} files listed, uploaded file listed: {any(f.id == created.id for f in files)}")(litellm.file_list(s3_bucket_name=bucket, **aws)))
show("4. read a batch result with only the output bucket passed",
     f"litellm.file_content(file_id='s3://{bucket}/litellm-batch-outputs/qa-output-{hexs}.jsonl', custom_llm_provider='bedrock', s3_output_bucket_name='{bucket}', aws_region_name='us-east-1').text",
     lambda: litellm.file_content(file_id=f"s3://{bucket}/litellm-batch-outputs/qa-output-{hexs}.jsonl", s3_output_bucket_name=bucket, **aws).text.strip())
show("5. read a file outside LiteLLM's folders, no legacy flag",
     f"litellm.file_content(file_id='s3://{bucket}/qa-legacy-{hexs}/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1')",
     lambda: litellm.file_content(file_id=f"s3://{bucket}/qa-legacy-{hexs}/legacy.jsonl", s3_bucket_name=bucket, **aws).text.strip())
show("6. the same read with allow_legacy_cloud_file_ids=True",
     f"litellm.file_content(file_id='s3://{bucket}/qa-legacy-{hexs}/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='{bucket}', allow_legacy_cloud_file_ids=True, aws_region_name='us-east-1').text",
     lambda: litellm.file_content(file_id=f"s3://{bucket}/qa-legacy-{hexs}/legacy.jsonl", s3_bucket_name=bucket, allow_legacy_cloud_file_ids=True, **aws).text.strip())
show("7. delete the uploaded file",
     f"litellm.file_delete(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='{bucket}', aws_region_name='us-east-1').deleted",
     lambda: litellm.file_delete(file_id=created.id, s3_bucket_name=bucket, **aws).deleted)

1. SDK reads back the file it uploaded

Before (9d972c8). The upload works, and reading it back with the same bucket fails

>>> litellm.create_file(file=open('sdk_batch.jsonl', 'rb'), purpose='batch', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').id
s3://litellm-lit7720-batch-qa-888/litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-b83012ca-a655-44cb-b4aa-ecd080d7ea91.jsonl

>>> litellm.file_content(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').text
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7). The same calls return the file's lines

>>> litellm.create_file(file=open('sdk_batch.jsonl', 'rb'), purpose='batch', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').id
s3://litellm-lit7720-batch-qa-888/litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-7e1e7a79-47cb-43af-a51d-5100b2d6228a.jsonl

>>> litellm.file_content(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').text
{"recordId": "s1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 1"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
{"recordId": "s2", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 2"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
2. SDK. A file in another bucket

Before (9d972c8)

>>> litellm.file_content(file_id='s3://litellm-qa-client-bucket-966715/litellm-bedrock-files/x.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_content(file_id='s3://litellm-qa-client-bucket-966715/litellm-bedrock-files/x.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
BedrockError: file_id bucket does not match the configured storage bucket
3. SDK. List files

Before (9d972c8)

>>> litellm.file_list(custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_list(custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
34 files listed, uploaded file listed: True
4. SDK. Read a batch result passing only the output bucket

Before (9d972c8)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/litellm-batch-outputs/qa-output-966715.jsonl', custom_llm_provider='bedrock', s3_output_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').text
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/litellm-batch-outputs/qa-output-966715.jsonl', custom_llm_provider='bedrock', s3_output_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').text
{"recordId": "q1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "qa object"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
5. SDK. A file outside LiteLLM's folders, no legacy flag

Before (9d972c8)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/qa-legacy-966715/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/qa-legacy-966715/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1')
BedrockError: file_id must reference a LiteLLM-managed storage object
6. SDK. The same file with `allow_legacy_cloud_file_ids=True`

Before (9d972c8)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/qa-legacy-966715/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', allow_legacy_cloud_file_ids=True, aws_region_name='us-east-1').text
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_content(file_id='s3://litellm-lit7720-batch-qa-888/qa-legacy-966715/legacy.jsonl', custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', allow_legacy_cloud_file_ids=True, aws_region_name='us-east-1').text
{"recordId": "q1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "qa object"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
7. SDK. Delete the uploaded file

Before (9d972c8)

>>> litellm.file_delete(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').deleted
ValueError: S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval.

After (b03cbd7)

>>> litellm.file_delete(file_id=created.id, custom_llm_provider='bedrock', s3_bucket_name='litellm-lit7720-batch-qa-888', aws_region_name='us-east-1').deleted
True
P1. Proxy. Upload a file to the model and read it back

Before (9d972c8)

$ FID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F model=bedrock-batch -F file=@sdk_batch.jsonl | jq -r .id); echo $FID
file-bGl0ZWxsbTpzMzovL2xpdGVsbG0tbGl0NzcyMC1iYXRjaC1xYS04ODgvbGl0ZWxsbS1iZWRyb2NrLWZpbGVzLXVzLmFudGhyb3BpYy5jbGF1ZGUtaGFpa3UtNC01LTIwMjUxMDAxLXYxLTAtYzViYjdkNGYtNzFmMy00NGJlLWIzOTgtZmYwYzMxZDcxNDRkLmpzb25sO21vZGVsLGJlZHJvY2stYmF0Y2g

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/files/$FID/content -H "Authorization: Bearer $KEY"
{"recordId": "s1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 1"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
{"recordId": "s2", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 2"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
HTTP 200

After (b03cbd7)

$ FID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F model=bedrock-batch -F file=@sdk_batch.jsonl | jq -r .id); echo $FID
file-bGl0ZWxsbTpzMzovL2xpdGVsbG0tbGl0NzcyMC1iYXRjaC1xYS04ODgvbGl0ZWxsbS1iZWRyb2NrLWZpbGVzLXVzLmFudGhyb3BpYy5jbGF1ZGUtaGFpa3UtNC01LTIwMjUxMDAxLXYxLTAtYzBiNzA5ZGUtYzVjNS00OTBhLTljN2EtMWVjZTZkZWM0NmQzLmpzb25sO21vZGVsLGJlZHJvY2stYmF0Y2g

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/files/$FID/content -H "Authorization: Bearer $KEY"
{"recordId": "s1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 1"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
{"recordId": "s2", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 2"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
HTTP 200
P2. Proxy. Retrieve its metadata

Before (9d972c8)

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY"
{"id":"file-bGl0ZWxsbTpzMzovL2xpdGVsbG0tbGl0NzcyMC1iYXRjaC1xYS04ODgvbGl0ZWxsbS1iZWRyb2NrLWZpbGVzLXVzLmFudGhyb3BpYy5jbGF1ZGUtaGFpa3UtNC01LTIwMjUxMDAxLXYxLTAtYzViYjdkNGYtNzFmMy00NGJlLWIzOTgtZmYwYzMxZDcxNDRkLmpzb25sO21vZGVsLGJlZHJvY2stYmF0Y2g","bytes":355,"created_at":1792533649,"filename":"litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-c5bb7d4f-71f3-44be-b398-ff0c31d7144d.jsonl","object":"file","purpose":"batch","status":"processed","expires_at":null,"status_details":null}
HTTP 200

After (b03cbd7)

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY"
{"id":"file-bGl0ZWxsbTpzMzovL2xpdGVsbG0tbGl0NzcyMC1iYXRjaC1xYS04ODgvbGl0ZWxsbS1iZWRyb2NrLWZpbGVzLXVzLmFudGhyb3BpYy5jbGF1ZGUtaGFpa3UtNC01LTIwMjUxMDAxLXYxLTAtYzBiNzA5ZGUtYzVjNS00OTBhLTljN2EtMWVjZTZkZWM0NmQzLmpzb25sO21vZGVsLGJlZHJvY2stYmF0Y2g","bytes":355,"created_at":1792533658,"filename":"litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-c0b709de-c5c5-490a-9c7a-1ece6dec46d3.jsonl","object":"file","purpose":"batch","status":"processed","expires_at":null,"status_details":null}
HTTP 200
P3. Proxy. List files for the model

Before (9d972c8)

$ FID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F model=bedrock-batch -F file=@sdk_batch.jsonl | jq -r .id); S3_ID=$(curl -s http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY" | jq -r .filename); echo $S3_ID
litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-e313cc20-895a-4d52-9f45-82078e992e4a.jsonl

$ curl -s -w "\nHTTP %{http_code}\n" "http://localhost:$PORT/v1/files?target_model_names=bedrock-batch&purpose=batch" -H "Authorization: Bearer $KEY" | jq -rR "fromjson? | \"\(.data | length) files listed, uploaded file listed: \([.data[].id] | any(endswith(\"$S3_ID\")))\" // ."
20 files listed, uploaded file listed: true

After (b03cbd7)

$ FID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F model=bedrock-batch -F file=@sdk_batch.jsonl | jq -r .id); S3_ID=$(curl -s http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY" | jq -r .filename); echo $S3_ID
litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-d4d05487-748c-423b-b43a-b13e965742ca.jsonl

$ curl -s -w "\nHTTP %{http_code}\n" "http://localhost:$PORT/v1/files?target_model_names=bedrock-batch&purpose=batch" -H "Authorization: Bearer $KEY" | jq -rR "fromjson? | \"\(.data | length) files listed, uploaded file listed: \([.data[].id] | any(endswith(\"$S3_ID\")))\" // ."
20 files listed, uploaded file listed: true
P4. Proxy. Delete it

Before (9d972c8)

$ curl -s -w "\nHTTP %{http_code}\n" -X DELETE http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY"
{"id":"s3://litellm-lit7720-batch-qa-888/litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-c5bb7d4f-71f3-44be-b398-ff0c31d7144d.jsonl","deleted":true,"object":"file"}
HTTP 200

After (b03cbd7)

$ curl -s -w "\nHTTP %{http_code}\n" -X DELETE http://localhost:$PORT/v1/files/$FID -H "Authorization: Bearer $KEY"
{"id":"s3://litellm-lit7720-batch-qa-888/litellm-bedrock-files-us.anthropic.claude-haiku-4-5-20251001-v1-0-c0b709de-c5c5-490a-9c7a-1ece6dec46d3.jsonl","deleted":true,"object":"file"}
HTTP 200
P5. Proxy. Managed batch, upload with `target_model_names` and create the batch

Before (9d972c8)

$ MFID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F target_model_names=bedrock-batch -F file=@batch.jsonl | jq -r .id); echo $MFID
bGl0ZWxsbV9wcm94eTphcHBsaWNhdGlvbi9vY3RldC1zdHJlYW07dW5pZmllZF9pZCwxMjRkNTRmNC0wNjJhLTQ2NTEtYWM1My00MDcxOGNmNGVkM2I7dGFyZ2V0X21vZGVsX25hbWVzLGJlZHJvY2stYmF0Y2g7bGxtX291dHB1dF9maWxlX2lkLHMzOi8vbGl0ZWxsbS1saXQ3NzIwLWJhdGNoLXFhLTg4OC9saXRlbGxtLWJlZHJvY2stZmlsZXMtdXMuYW50aHJvcGljLmNsYXVkZS1oYWlrdS00LTUtMjAyNTEwMDEtdjEtMC0xZmYxYTI5OC0yYWI4LTRkMDctOGY2NC02YTBlYzA4ZmZlY2IuanNvbmw7bGxtX291dHB1dF9maWxlX21vZGVsX2lkLDJkNGYwMWI3MGE5NTBjNzllOTg5OTlhOTZlN2Q5MTY1NTJmOWIwZGE1YWNiOTgzMTNlNjY4NzMwODQxNjc2ODA

$ curl -s http://localhost:$PORT/v1/files/$MFID/content -H "Authorization: Bearer $KEY" | head -c 200; echo; curl -s -o /dev/null -w "HTTP %{http_code}\n" http://localhost:$PORT/v1/files/$MFID/content -H "Authorization: Bearer $KEY"
{"recordId": "r1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 1"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
{"recordId": "r2", "mo
HTTP 200

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/batches -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d "{\"input_file_id\": \"$MFID\", \"endpoint\": \"/v1/chat/completions\", \"completion_window\": \"24h\"}"
{"id":"bGl0ZWxsbV9wcm94eTttb2RlbF9pZDoyZDRmMDFiNzBhOTUwYzc5ZTk4OTk5YTk2ZTdkOTE2NTUyZjliMGRhNWFjYjk4MzEzZTY2ODczMDg0MTY3NjgwO2xsbV9iYXRjaF9pZDphcm46YXdzOmJlZHJvY2s6dXMtZWFzdC0xOjg4ODYwMjIyMzQyODptb2RlbC1pbnZvY2F0aW9uLWpvYi9tajVuMXhwYmhmOTk","completion_window":"24h","created_at":1792533649,"endpoint":"/v1/chat/completions","input_file_id":"bGl0ZWxsbV9wcm94eTphcHBsaWNhdGlvbi9vY3RldC1zdHJlYW07dW5pZmllZF9pZCwxMjRkNTRmNC0wNjJhLTQ2NTEtYWM1My00MDcxOGNmNGVkM2I7dGFyZ2V0X21vZGVsX25hbWVzLGJlZHJvY2stYmF0Y2g7bGxtX291dHB1dF9maWxlX2lkLHMzOi8vbGl0ZWxsbS1saXQ3NzIwLWJhdGNoLXFhLTg4OC9saXRlbGxtLWJlZHJvY2stZmlsZXMtdXMuYW50aHJvcGljLmNsYXVkZS1oYWlrdS00LTUtMjAyNTEwMDEtdjEtMC0xZmYxYTI5OC0yYWI4LTRkMDctOGY2NC02YTBlYzA4ZmZlY2IuanNvbmw7bGxtX291dHB1dF9maWxlX21vZGVsX2lkLDJkNGYwMWI3MGE5NTBjNzllOTg5OTlhOTZlN2Q5MTY1NTJmOWIwZGE1YWNiOTgzMTNlNjY4NzMwODQxNjc2ODA","object":"batch","status":"validating","cancelled_at":null,"cancelling_at":null,"completed_at":null,"error_file_id":null,"errors":null,"expired_at":null,"expires_at":null,"failed_at":null,"finalizing_at":null,"in_progress_at":null,"metadata":{},"model":null,"output_file_id":null,"request_counts":null,"usage":null}
HTTP 200

After (b03cbd7)

$ MFID=$(curl -s http://localhost:$PORT/v1/files -H "Authorization: Bearer $KEY" -F purpose=batch -F target_model_names=bedrock-batch -F file=@batch.jsonl | jq -r .id); echo $MFID
bGl0ZWxsbV9wcm94eTphcHBsaWNhdGlvbi9vY3RldC1zdHJlYW07dW5pZmllZF9pZCxjNWVjYjlhZC1iY2E4LTQwN2YtOGMxZi0yMDQwMmNmZDc4Yjk7dGFyZ2V0X21vZGVsX25hbWVzLGJlZHJvY2stYmF0Y2g7bGxtX291dHB1dF9maWxlX2lkLHMzOi8vbGl0ZWxsbS1saXQ3NzIwLWJhdGNoLXFhLTg4OC9saXRlbGxtLWJlZHJvY2stZmlsZXMtdXMuYW50aHJvcGljLmNsYXVkZS1oYWlrdS00LTUtMjAyNTEwMDEtdjEtMC1kZDk1YWVlNi04OTU1LTQwYjUtYjY0Yy00MTI1NzJjZDM0ZmYuanNvbmw7bGxtX291dHB1dF9maWxlX21vZGVsX2lkLDJkNGYwMWI3MGE5NTBjNzllOTg5OTlhOTZlN2Q5MTY1NTJmOWIwZGE1YWNiOTgzMTNlNjY4NzMwODQxNjc2ODA

$ curl -s http://localhost:$PORT/v1/files/$MFID/content -H "Authorization: Bearer $KEY" | head -c 200; echo; curl -s -o /dev/null -w "HTTP %{http_code}\n" http://localhost:$PORT/v1/files/$MFID/content -H "Authorization: Bearer $KEY"
{"recordId": "r1", "modelInput": {"messages": [{"role": "user", "content": [{"type": "text", "text": "say ok 1"}]}], "max_tokens": 5, "anthropic_version": "bedrock-2023-05-31"}}
{"recordId": "r2", "mo
HTTP 200

$ curl -s -w "\nHTTP %{http_code}\n" http://localhost:$PORT/v1/batches -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d "{\"input_file_id\": \"$MFID\", \"endpoint\": \"/v1/chat/completions\", \"completion_window\": \"24h\"}"
{"id":"bGl0ZWxsbV9wcm94eTttb2RlbF9pZDoyZDRmMDFiNzBhOTUwYzc5ZTk4OTk5YTk2ZTdkOTE2NTUyZjliMGRhNWFjYjk4MzEzZTY2ODczMDg0MTY3NjgwO2xsbV9iYXRjaF9pZDphcm46YXdzOmJlZHJvY2s6dXMtZWFzdC0xOjg4ODYwMjIyMzQyODptb2RlbC1pbnZvY2F0aW9uLWpvYi92cmlobXZobmo5a2I","completion_window":"24h","created_at":1792533659,"endpoint":"/v1/chat/completions","input_file_id":"bGl0ZWxsbV9wcm94eTphcHBsaWNhdGlvbi9vY3RldC1zdHJlYW07dW5pZmllZF9pZCxjNWVjYjlhZC1iY2E4LTQwN2YtOGMxZi0yMDQwMmNmZDc4Yjk7dGFyZ2V0X21vZGVsX25hbWVzLGJlZHJvY2stYmF0Y2g7bGxtX291dHB1dF9maWxlX2lkLHMzOi8vbGl0ZWxsbS1saXQ3NzIwLWJhdGNoLXFhLTg4OC9saXRlbGxtLWJlZHJvY2stZmlsZXMtdXMuYW50aHJvcGljLmNsYXVkZS1oYWlrdS00LTUtMjAyNTEwMDEtdjEtMC1kZDk1YWVlNi04OTU1LTQwYjUtYjY0Yy00MTI1NzJjZDM0ZmYuanNvbmw7bGxtX291dHB1dF9maWxlX21vZGVsX2lkLDJkNGYwMWI3MGE5NTBjNzllOTg5OTlhOTZlN2Q5MTY1NTJmOWIwZGE1YWNiOTgzMTNlNjY4NzMwODQxNjc2ODA","object":"batch","status":"validating","cancelled_at":null,"cancelling_at":null,"completed_at":null,"error_file_id":null,"errors":null,"expired_at":null,"expires_at":null,"failed_at":null,"finalizing_at":null,"in_progress_at":null,"metadata":{},"model":null,"output_file_id":null,"request_counts":null,"usage":null}
HTTP 200

Type

🐛 Bug Fix
🧹 Refactoring

Caveats (if any)

High

  • An allow_legacy_cloud_file_ids string that is not a boolean now makes Router init fail
    • "enabled" boots on base and raises ValidationError on head, now that the field is a typed bool | None

Medium

  • Proxy file reads no longer have the server-only bucket check
  • The live proof misses proxy paths whose credential plumbing changed
    • The batch cost poller output read, unified batch retrieve, the per-model legacy flag, the batch rate limiter and Router SDK calls. P5 stops at validating

Low

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] Appears safe to merge after #47496, with no new actionable issues found

Summary

Bedrock file calls now use the bucket passed by the SDK caller, with environment variables as fallback

  • Bedrock file calls use the S3 bucket named on the call.
  • Cloud file calls can allow older file IDs when their settings say so.

Reviews (6) · Last reviewed commit: "Merge branch 'litellm_proxy_client_stora..." · Reviewed by Greptile

…drop the proxy credential snapshot

The SDK dropped s3_bucket_name before it reached Bedrock, so litellm.file_content with that kwarg failed with "S3 bucket_name is required" (LIT-9501). Bedrock file calls now read the bucket from the call, else AWS_S3_BUCKET_NAME, and the proxy passes the deployment's bucket settings as plain kwargs instead of a separate snapshot. Request-body bucket fields are gated by the proxy allowlist
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ryan-crabbe-berri
ryan-crabbe-berri force-pushed the litellm_bedrock_files_trust_call_bucket branch from e7b3930 to 8e1b809 Compare October 20, 2026 17:48
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…trieve

The lookup only fed the removed bucket snapshot. The router now passes the
deployment's bucket straight through.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 22df560. Configure here.

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@litereview guide

…drock_files_trust_call_bucket

# Conflicts:
#	litellm/litellm_core_utils/cloud_storage_security.py
#	tests/unit/llms/vertex_ai/files/test_vertex_ai_files_transformation.py
@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

New commits were pushed. This review covers 22df560498b2.

⚠️ guide

Open preview

Scope: full · Full PR review.

Completed · Some checks not run.

Today an SDK caller who uploads a Bedrock batch file with s3_bucket_name="my-bucket" can't read it back. file_content, file_list and file_delete all fail with S3 bucket_name is required, even though the call names the bucket.

The walkthrough, one stop at a time

  1. Upload with your bucket. create_file already uses the bucket they pass. Same both ways.
  2. Ask to read it back. The read call names the same bucket. Same both ways.
  3. Settings get collected. s3_bucket_name, s3_output_bucket_name and allow_legacy_cloud_file_ids were missing from the list of call settings LiteLLM passes along, so they got dropped. The fix adds them.
  4. Pick the bucket. Breaks here / Fixed here. Bedrock used to accept a bucket only from a read-only snapshot that the proxy builds, or from AWS_S3_BUCKET_NAME. Now it takes the call's s3_bucket_name first, then the env var.
  5. Check the file id. The check itself is unchanged: same bucket, inside LiteLLM's folders. Before the fix the call never got this far. Now a file in some other bucket is still refused.
  6. S3 read and reply. Before: an error. After: they get the file's lines back. List and delete work too.

What changes for the caller: SDK users can now read, list and delete their Bedrock files by passing the bucket. On the proxy, a per-deployment allow_legacy_cloud_file_ids now actually takes effect. The proxy's private snapshot route is gone, and deployment values now override request values on model-routed file calls.

Before you merge: Bedrock now accepts whatever bucket arrives on the call. On the proxy, that is only safe once #47496 lands, because #47496 is what stops clients from sending their own bucket. Merge #47496 first and check that it covers every file route.

Tests added: Eight unit-level additions or changes:

  • SDK read from the named bucket, and refusal of a file in another bucket (fake S3)
  • call vs env bucket order
  • the legacy flag surviving the router
  • deployment values overriding request values
  • the cost poller reading a Bedrock output file via respx
  • updated Vertex legacy-flag tests

I ran the bucket, legacy, SDK and prepare-data tests (13 passed) and the cost-poller test (1 passed). A quick script with a fake S3 gave the same results as the PR's live run: the read succeeds, and the other bucket is refused.

Black box coverage: Nay. The existing e2e proxy file-content test still covers the proxy read. Nothing black box covers:

  • the SDK passing s3_bucket_name
  • refusal of a file in another bucket
  • the per-deployment legacy flag
  • Bedrock batch cost reads
Checks and execution details
  • Passed · Targeted unit tests for bucket lookup, legacy flag, SDK read and proxy credential merge (optional): Ran pytest tests/unit/llms/bedrock/files/test_bedrock_files_handler.py tests/unit/proxy/openai_files_endpoint/test_files_common_utils.py tests/unit/test_azure_ad_token_credential_resolution.py -k "bucket or legacy or sdk or Prepare": 13 passed.
  • Passed · Cost poller reads Bedrock output from deployment bucket (optional): Ran pytest tests/unit/proxy/common_utils/test_check_batch_cost.py -k output_fetch: 1 passed.
  • Passed · Local SDK repro with fake S3 transport (optional): Called litellm.file_content with s3_bucket_name on this checkout, using an httpx.MockTransport S3. Matching bucket returned the body. some-other-bucket raised BedrockError: file_id bucket does not match the configured storage bucket. No bucket raised the new S3 bucket_name is required. Pass 's3_bucket_name'... message.
  • Passed · Black box coverage review (required): Read tests/e2e/batches/test_batches_e2e.py, tests/e2e/coverage_registry/llm_nonconversational.yaml and tests/integration/providers/test_bedrock_batch_files_wire.py. Only the proxy unified file-content path is covered. The SDK bucket, other-bucket refusal, deployment legacy flag and Bedrock cost-read paths are not. Verdict: Nay.
  • Not run · Live AWS S3 run (optional): There were no AWS credentials in the sandbox. The page quotes the live before/after results from the PR description and labels them as such.

View review · Reviewed 22df560498b2

@mateo-berri mateo-berri changed the title fix(bedrock): use the S3 bucket passed to SDK file calls instead of requiring proxy config fix(bedrock)!: use the S3 bucket passed to SDK file calls instead of requiring proxy config Oct 20, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

No correctness findings.

Checks and execution details
  • Passed · Real testing evidence (required): litellm/llms/bedrock/files/transformation.py is in scope. It changes how the Bedrock files request picks the S3 bucket: the bucket now comes from the call's s3_bucket_name or s3_output_bucket_name, then the env vars, instead of a MappingProxyType snapshot. The legacy-id flag now comes from the call too.

The PR description includes inspectable manual E2E evidence for that change. It names the real bucket and region, the real litellm.create_file, file_content, file_list and file_delete SDK calls, a proxy config and curl round trip, and before/after output at 943f0b8b85 and 8e1b8093a7. Covered cases:

  • Read back a file the SDK uploaded.
  • Reject a file in a mismatched bucket.
  • List files.
  • Delete a file.
  • Read with only the output bucket set.
  • Reject a legacy object without the flag, then allow it with allow_legacy_cloud_file_ids=True.
  • Proxy upload then read, returning HTTP 200.

The GitHub compare from 8e1b8093a7 to head b03cbd70f1 shows only changes merged in from main for the PR's touched files: decode passes in cloud_storage_security.py, the admin raw-id gate in files_endpoints.py, and unrelated router types. None of them touch bucket resolution, so the evidence still covers the head. Updated unit tests in tests/unit/llms/bedrock/files/* and tests/unit/llms/vertex_ai/files/* also passed locally.

  • Passed · Compatibility requirements (required): Two real compatibility changes:
  1. A per-deployment allow_legacy_cloud_file_ids: true used to be dropped, because CredentialLiteLLMParams lacked the field and Bedrock/Vertex only read the snapshot. It now takes effect.
  2. The text of _S3_BUCKET_REQUIRED_ERROR changed.

The title carries fix(bedrock)!:, and the description explains both impacts and what to check before upgrading. The removed add_internal_model_credentials, add_trusted_model_credentials_to_litellm_params and include_internal_credentials kwarg were internal and are listed under the caveats. No other supported input changes: the proxy request-body ban on s3_bucket_name, s3_output_bucket_name and allow_legacy_cloud_file_ids (auth_utils.py:439-442) is unchanged.

  • Passed · Changed behavior and result consistency (required): Traced paths:

  • SDK: files/main.py calls get_litellm_params. OPTIONAL_KWARGS_KEYS now includes the S3 and legacy-flag keys, which the Bedrock _resolve_managed_s3_object and _listing_bucket_name helpers and the Vertex _parse_gcs_uri helper read. A non-empty call value beats the env var; an empty string falls back to the env var.

  • Proxy routed calls: Router._ageneric_api_call_with_fallbacks_helper and aretrieve_batch merge the deployment litellm_params into the call.

  • Proxy direct calls: prepare_data_with_credentials applies data.update(credentials), so deployment values win.

  • Managed-file retrieve: uses get_deployment_credentials_with_provider, which now carries allow_legacy_cloud_file_ids.

  • Batch cost accounting: extract_file_access_credentials now forwards the bucket keys.

  • Client injection: blocked by is_request_body_safe. The check runs after populate_request_with_path_params folds query params into the request data, and it covers nested extra_body and metadata. Only an admin opt-in or the allowed_client_side_s3_buckets allowlist lets a client value through.

I found no defect.

Local run: the affected suites (Bedrock/Vertex files, batches, files endpoints, model-based routing, check_batch_cost, managed files hooks, batches endpoints, Azure AD credential) gave 1581 passed and 21 failed. All 21 failures were ImportError: cannot import name 'Json' from 'prisma', an environment issue. After prisma generate, the 3 affected files passed 450/450.

  • Passed · Targeted unit test run (optional): pytest -n 8 on 12 affected test files: 1581 passed, 2 skipped, 21 environment failures from the missing Prisma client. After prisma generate --schema litellm/proxy/schema.prisma, tests/unit/enterprise/proxy/test_managed_files_hook.py, tests/unit/enterprise/proxy/hooks/test_managed_files.py and tests/unit/proxy/batches_endpoints/test_endpoints.py passed 450/450.

View review · Reviewed b03cbd70f1ac

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@ryan-crabbe-berri could you fix the Router init High and the error-text Low, and decide the server-snapshot Medium in Caveats? I'll review again after

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@ryan-crabbe-berri
ryan-crabbe-berri merged commit 7da180a into litellm_proxy_client_storage_allowlist Nov 6, 2026
90 of 91 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_bedrock_files_trust_call_bucket branch November 6, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants