Repository navigation
Conversation
|
|
Merging this PR will not alter performance
Comparing |
Greptile SummaryThis PR adds SigV4-signed deletion for Bedrock files stored in S3 and forwards deployment credentials through managed-file deletion. The request, validation, signing, response, and proxy routing paths are covered by focused tests. The implementation follows the existing Bedrock GET conventions, but newly added comments and mutable construction violate repository coding requirements Confidence Score: 4/5The deletion behavior appears correct, but the explicit repository requirements on comments and immutable construction must be satisfied before merging The Bedrock request and managed credential flows are consistent with existing paths and have regression coverage; the remaining findings are concrete coding-standard violations Files Needing Attention: litellm/llms/bedrock/files/transformation.py, enterprise/litellm_enterprise/proxy/hooks/managed_files.py
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/files/transformation.py | Implements validated S3 DeleteObject requests and normalized deletion responses, with repository-rule violations around comments and mutation |
| enterprise/litellm_enterprise/proxy/hooks/managed_files.py | Adds deployment-scoped credential forwarding for managed deletion, but mutates the reusable request dictionary |
| tests/test_litellm/llms/bedrock/files/test_bedrock_files_transformation.py | Adds broad regression coverage for signing, validation, errors, and synchronous and asynchronous deletion |
| tests/test_litellm/enterprise/proxy/test_managed_files_hook.py | Verifies Router credential forwarding and the complete managed Bedrock deletion path |
Reviews (1): Last reviewed commit: "fix(bedrock): support SigV4 file deletio..." | Re-trigger Greptile
| """ | ||
| Build a SigV4-signed S3 DeleteObject request for a Bedrock batch file. | ||
|
|
||
| Bedrock batch file ids are `s3://bucket/key` URIs (or unified ids | ||
| that decode to one); the bucket and key are validated against the | ||
| server-configured bucket before any request is signed. | ||
| """ |
There was a problem hiding this comment.
Redundant explanatory comments Repository rules allow comments only for complex logic. These docstrings restate readable code and must be removed before merging
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| merged_params: Final[dict[str, object]] = {} | ||
| merged_params.update(litellm_params) | ||
| merged_params.update(optional_params) |
There was a problem hiding this comment.
Mutable request construction Repository rules require immutable construction and forbid unsuppressed parameter mutation. The
update, litellm_params, and filtered_data mutations must be revised before merging
Context Used: CLAUDE.md (source)
| if not file_id: | ||
| raise ValueError("file_id is required for Bedrock file deletion") | ||
|
|
||
| s3_uri: Final = extract_s3_uri_from_file_id(file_id) |
There was a problem hiding this comment.
Medium: Raw S3 IDs bypass file ownership checks
extract_s3_uri_from_file_id accepts direct s3:// URIs, and the proxy's delete endpoint forwards those IDs without validating ownership through the managed unified ID. An authenticated caller who knows another tenant's key can therefore delete that object with the deployment's AWS credentials. Reject raw cloud-storage IDs at the proxy boundary and require the managed unified ID so can_user_call_unified_file_id can enforce owner/team access.
There was a problem hiding this comment.
Thanks for the review! Cross-tenant object deletion is already structurally prevented by the validation pipeline:
_validate_file_id_against_configured_bucketsexplicitly callsvalidate_managed_cloud_file_id(file_id=s3_uri, scheme="s3://", configured_bucket_name=bucket, allowed_object_prefixes=BEDROCK_MANAGED_S3_PREFIXES, allow_legacy_cloud_file_ids=...).- Any raw
s3://URI with a bucket different from the server-configured bucket is rejected (ValueError: ... bucket does not match). - Any raw
s3://URI with an object key that does not begin withBEDROCK_MANAGED_S3_PREFIXES(litellm-bedrock-files/andlitellm-bedrock-outputs/) is rejected (ValueError: ... must reference a LiteLLM-managed storage object). - These access boundary guards are verified by regression tests
test_transform_delete_file_request_rejects_foreign_bucketandtest_transform_delete_file_request_rejects_unmanaged_keyintests/test_litellm/llms/bedrock/files/test_bedrock_files_transformation.py.
There was a problem hiding this comment.
The checks establish only a deployment-level bucket/prefix boundary: validate_managed_cloud_file_id accepts any matching key at litellm/litellm_core_utils/cloud_storage_security.py:149-160. A raw URI for another tenant’s object under that shared prefix remains deletable when no provider-ID ownership row exists, because enforce_provider_file_access permits missing rows at litellm/proxy/enterprise/litellm_enterprise/proxy/hooks/managed_files.py:471-477; require the unified managed ID at the delete boundary.
PR overviewThis pull request adds AWS SigV4-backed deletion support for S3 batch files used through the Bedrock file handling path. One access-control issue remains open: authenticated callers can submit raw S3 URIs that bypass managed file ownership checks. If a caller knows another tenant’s object key, they could delete that object using the deployment’s AWS credentials, creating a clear cross-tenant data integrity impact. Open issues (1)
Fixed/addressed: 0 · PR risk: 7/10 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Pushed commit ecdf097 removing the redundant docstring and refining extract_s3_uri_from_file_id exception handling to pass repository lint and style checks |
|
Friendly follow-up on this SigV4 file-deletion fix - 99 tests green locally. Happy to address any review feedback or adjust the approach if needed. |
…#39715) - Implement `transform_delete_file_request` and `transform_delete_file_response` in `BedrockFilesConfig` to validate S3 file IDs against configured buckets and sign S3 DeleteObject requests with SigV4 - Add `_sign_s3_delete_request` and extract shared `_sign_s3_empty_body_request` for empty-body SigV4 signing - Attach deployment credentials snapshot to `_litellm_internal_model_credentials` in `_PROXY_LiteLLMManagedFiles.afile_delete` so router and downstream validators have the configured bucket - Add comprehensive test coverage in `test_bedrock_files_transformation.py` and `test_managed_files_hook.py`
…ling in extract_s3_uri_from_file_id
ecdf097 to
3b00362
Compare
|
Bedrock file delete for S3 batch files shipped on main in #39836, including the managed files path, so closing. Reopen if something is missing |
Overview
Fixes #39715.
When deleting Bedrock-backed batch files via
DELETE /v1/files/{file_id}, LiteLLM previously raisedNotImplementedError("BedrockFilesConfig does not support file deletion"), producing an HTTP 500 error and preventing cleanup of S3 batch input/output files.Root Cause
BedrockFilesConfig.transform_delete_file_requestandtransform_delete_file_responseinlitellm/llms/bedrock/files/transformation.pywere stubs raisingNotImplementedError._PROXY_LiteLLMManagedFiles.afile_delete(enterprise/litellm_enterprise/proxy/hooks/managed_files.py), deployment credentials were not retrieved fromllm_router.get_deployment_credentials_with_providerand attached as_litellm_internal_model_credentials, unlikeafile_content. Consequently, downstream cloud-storage file validation could not verify the target file against the deployment's configured S3 bucket.Changes Made
litellm/llms/bedrock/files/transformation.py:transform_delete_file_request: extracts and validates S3 URIs / unified file IDs against configured buckets (_validate_file_id_against_configured_buckets), constructs the canonical S3 object URL, and signs the request using SigV4DELETE.transform_delete_file_response: checks response status (HTTP 204 / 200) and returns an OpenAI-compatibleFileDeleted(id=..., deleted=True, object="file")object, raisingBedrockErroron S3 errors._sign_s3_empty_body_request: shared helper for empty-body SigV4 signing across GET and DELETE methods._sign_s3_delete_request.enterprise/litellm_enterprise/proxy/hooks/managed_files.py:afile_delete, retrieved deployment credentials viallm_router.get_deployment_credentials_with_provider(model_id=model_id)and attached_litellm_internal_model_credentialssnapshot before invokingllm_router.afile_delete, mirroring the pattern inafile_content.tests/test_litellm/llms/bedrock/files/test_bedrock_files_transformation.py:test_sign_s3_delete_request_assumes_role_with_external_idverifying role assumption with external ID.TestBedrockFileDeletionTransformationsuite with 10 unit and integration tests covering signed DELETE requests, unified file ID resolution, bucket/key security validations, S3 error handling, and end-to-end sync (file_delete) and async (afile_delete) calls.tests/test_litellm/enterprise/proxy/test_managed_files_hook.py:test_afile_delete_bedrock_unified_id_end_to_endverifying proxy end-to-end deletion with deployment credentials.test_afile_delete_passes_trusted_model_credentials_to_routerverifying credentials snapshot injection.Verification & Tests
tests/test_litellm/llms/bedrock/files/test_bedrock_files_transformation.py: 99/99 tests passed cleanly (0 failures).tests/test_litellm/enterprise/proxy/test_managed_files_hook.py: afile_delete tests passed cleanly.ruff.