internally retried PUT requests can send incomplete data when a file handle in given as `data` · Issue #13329 · aio-libs/aiohttp · GitHub
Skip to content

internally retried PUT requests can send incomplete data when a file handle in given as data #13329

Closed

Description

@bhearsum

Describe the bug

When an open file handle is given with a PUT request it is internally converted to a BufferedReaderPayload. Before the request is sent, the file handle is read and advanced when preparing the data. If certain error types are hit a retry happens within _request after that point. A new BufferedReaderPayload is constructed from the same underlying file handle, which has now advanced beyond what has been sent. When the data is prepared this time, it is missing an earlier chunk of data.

Included is a script with a minimal test case.

To Reproduce

Run the attached script.

Expected behavior

Internal retries should reset file handlers back to their original position (whether that's 0, or the start of the previous chunk that failed to send).

Logs/tracebacks

n/a

Python Version

3.14.3

aiohttp Version

Name: aiohttp
Version: 3.14.3
Location: /home/bhearsum/tmp/2026-08-05/bad/.venv/lib/python3.14/site-packages
Requires: aiohappyeyeballs, aiosignal, attrs, frozenlist, multidict, propcache, yarl
Required-by:

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.7.1
Location: /home/bhearsum/tmp/2026-08-05/bad/.venv/lib/python3.14/site-packages
Requires:
Required-by: aiohttp, yarl

propcache Version

Name: propcache
Version: 0.5.2
Location: /home/bhearsum/tmp/2026-08-05/bad/.venv/lib/python3.14/site-packages
Requires:
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarlName: yarl
Version: 1.24.5
Location: /home/bhearsum/tmp/2026-08-05/bad/.venv/lib/python3.14/site-packages
Requires: idna, multidict, propcache
Required-by: aiohttp

OS

Linux

Related component

Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Activity

  1. Dreamsorcerer commented on Aug 5, 2026

    @Dreamsorcerer
    Member

    I think it should rewind to the start of the file.

    @aiolibsbot implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions