Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewind filehandle request bodies before retrying requests #1444

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dandi/dandiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
url,
result.text,
)
if data is not None and hasattr(data, "seek"):
data.seek(0)

Check warning on line 237 in dandi/dandiapi.py

View check run for this annotation

Codecov / codecov/patch

dandi/dandiapi.py#L237

Added line #L237 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could/should we may be add a test which would trigger such a case by e.g. shimming self.session.request and always failing upon first try after reading the file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responses doesn't seem to support requests where data is a filehandle: getsentry/responses#719

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, if no easy way to test ATM, I am ok to proceed to see it fixed and others to give it a shot. Adding release label as well.

result.raise_for_status()
except Exception as e:
if isinstance(e, requests.HTTPError):
Expand Down
Loading