Skip to content

Fix retries rewinding a streaming body to position 0 - #3874

Open
simethan wants to merge 1 commit into
boto:developfrom
simethan:fix/retry-rewind-to-initial-position-3873
Open

simethan wants to merge 1 commit into
boto:developfrom
simethan:fix/retry-rewind-to-initial-position-3873

Conversation

@simethan

Copy link
Copy Markdown

Fixes #3873

Description of changes

Retries rewind a streaming body to position 0 instead of its initial
position, silently corrupting the retried request when the body starts
at a non-zero offset (e.g. a file object positioned part-way through).

  • AWSPreparedRequest now records the body's position at prepare time
    and reset_stream() seeks back to that position instead of 0.
  • AwsChunkedWrapper now records the wrapped stream's position at wrap
    time and seek() rewinds to it instead of 0, so the chunked/checksum
    path is fixed too.

Bodies starting at position 0 behave exactly as before.

Description of tests

  • New regression tests in test_awsrequest.py (prepared request resets
    to a non-zero initial position), test_httpchecksum.py (chunked
    wrapper seek returns to the wrap-time position), and test_endpoint.py
    (end-to-end retry through Endpoint.make_request resends the same
    bytes; seek count unchanged at 8).
  • tests/unit/test_awsrequest.py, test_httpchecksum.py,
    test_endpoint.py: 150 passed, 6 skipped.
  • ruff check and ruff format --check clean.

Generated by AI tools, and reviewed by Ethan Sim.

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.

Retries rewind a streaming body to position 0 instead of its initial position

1 participant