Skip to content

fix: pass delete_objects to get_botocore_valid_kwargs in _delete_objects - #3433

Open
hsusul wants to merge 1 commit into
aws:mainfrom
hsusul:fix/s3-delete-objects-additional-kwargs
Open

fix: pass delete_objects to get_botocore_valid_kwargs in _delete_objects#3433
hsusul wants to merge 1 commit into
aws:mainfrom
hsusul:fix/s3-delete-objects-additional-kwargs

Conversation

@hsusul

@hsusul hsusul commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes an issue where awswrangler.s3.delete_objects passed function_name="list_objects_v2" instead of function_name="delete_objects" to get_botocore_valid_kwargs().

Root Cause

In awswrangler/s3/_delete.py, _delete_objects called:

extra_kwargs: dict[str, Any] = get_botocore_valid_kwargs(
    function_name="list_objects_v2", s3_additional_kwargs=s3_additional_kwargs
)

Because of this:

  1. Valid S3 delete_objects parameters passed in s3_additional_kwargs (e.g., BypassGovernanceRetention, MFA, ChecksumAlgorithm) were filtered out and silently ignored because they are not valid parameters for list_objects_v2.
  2. Conversely, parameters valid for list_objects_v2 but invalid for delete_objects (such as Delimiter or ContinuationToken) were incorrectly preserved and passed to s3_client.delete_objects().

Fix

Changed function_name="list_objects_v2" to function_name="delete_objects" in awswrangler/s3/_delete.py.

Testing

  • Added regression test test_s3_delete_objects_additional_kwargs in tests/unit/test_moto.py verifying that delete_objects-specific parameters (BypassGovernanceRetention, RequestPayer) are retained and passed to s3_client.delete_objects(), while non-delete_objects parameters (Delimiter) are filtered out.
  • Verified with pytest tests/unit/test_moto.py, ruff check, ruff format --check, and mypy.
  • No AWS credentials or live AWS infrastructure required for testing.

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.

1 participant