Skip to content

Implement delete_objects method#18

Merged
chaen merged 4 commits intomasterfrom
copilot/implement-delete-objects-method-again
Mar 5, 2026
Merged

Implement delete_objects method#18
chaen merged 4 commits intomasterfrom
copilot/implement-delete-objects-method-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

Adds delete_objects to both sync Client and async AsyncClient, implementing the S3 multi-object delete API (POST /{bucket}?delete).

Changes

  • presigner.py: Add query_string param to sign_request_headers so ?delete= is included in the SigV4 canonical request
  • _base.py: Add _prepare_delete_objects (XML body construction, Content-MD5, signing) and _parse_delete_objects_response (XML response parsing with namespace handling)
  • client.py / aio/client.py: Add POST to _execute_request and public delete_objects method
  • tests: Sync and async coverage for normal deletion, quiet mode, and parameter validation
  • benchmarks: Added delete_objects benchmarks to all 4 benchmark test files (sync, sync CM, async, async CM)

XML values are escaped via xml.sax.saxutils.escape to prevent injection.

Usage

response = client.delete_objects(
    Bucket="mybucket",
    Delete={
        "Objects": [{"Key": "file1.txt"}, {"Key": "file2.txt"}],
        "Quiet": False,
    },
)
# response["Deleted"] -> [{"Key": "file1.txt"}, {"Key": "file2.txt"}]
Original prompt

This section details on the original issue you should resolve

<issue_title>Implementente delete_objects method</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 5, 2026 12:42
Add `delete_objects` method to both `Client` and `AsyncClient` that
performs S3 multi-object delete via POST request with XML payload.

Changes:
- presigner.py: Add optional `query_string` param to `sign_request_headers`
- _base.py: Add `_prepare_delete_objects` and `_parse_delete_objects_response`
- client.py: Add POST support to `_execute_request` and `delete_objects` method
- aio/client.py: Add POST support to `_execute_request` and `delete_objects` method
- tests: Add sync and async tests for delete_objects

Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>
Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement delete_objects method Implement delete_objects method Mar 5, 2026
@chrisburr
Copy link
Copy Markdown
Member

@copilot

  • pre-commit needs fixing
  • the delete call should be included in the benchmarking

Fix ruff format issues (line length) in source files and add
delete_objects benchmarks to all 4 benchmark test files:
- test_benchmark.py (sync)
- test_benchmark_cm.py (sync context manager)
- test_benchmark_aio.py (async)
- test_benchmark_aio_cm.py (async context manager)

Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 5, 2026

@copilot

  • pre-commit needs fixing
    ...

Fixed in 66a629b:

  • Applied ruff format fixes for line length violations in source files; pre-commit now passes cleanly
  • Added delete_objects benchmarks to all 4 benchmark files (test_benchmark.py, test_benchmark_cm.py, test_benchmark_aio.py, test_benchmark_aio_cm.py)

@chaen chaen marked this pull request as ready for review March 5, 2026 14:54
@chaen chaen merged commit 2566b29 into master Mar 5, 2026
11 checks passed
chaen pushed a commit that referenced this pull request Mar 5, 2026
* Initial plan

* Implement delete_objects method for sync and async clients

Add `delete_objects` method to both `Client` and `AsyncClient` that
performs S3 multi-object delete via POST request with XML payload.

Changes:
- presigner.py: Add optional `query_string` param to `sign_request_headers`
- _base.py: Add `_prepare_delete_objects` and `_parse_delete_objects_response`
- client.py: Add POST support to `_execute_request` and `delete_objects` method
- aio/client.py: Add POST support to `_execute_request` and `delete_objects` method
- tests: Add sync and async tests for delete_objects

Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>

* Fix XML injection vulnerability in delete_objects XML body construction

Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>

* Fix pre-commit formatting and add delete_objects benchmarks

Fix ruff format issues (line length) in source files and add
delete_objects benchmarks to all 4 benchmark test files:
- test_benchmark.py (sync)
- test_benchmark_cm.py (sync context manager)
- test_benchmark_aio.py (async)
- test_benchmark_aio_cm.py (async context manager)

Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: chrisburr <5220533+chrisburr@users.noreply.github.com>
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.

Implementente delete_objects method

3 participants