Skip to content

Do not retry uploads with non-replayable file streams - #738

Open
CAOShurong wants to merge 1 commit into
DagsHub:mainfrom
CAOShurong:fix-upload-stream-retry
Open

CAOShurong wants to merge 1 commit into
DagsHub:mainfrom
CAOShurong:fix-upload-stream-retry

Conversation

@CAOShurong

Copy link
Copy Markdown

Refs #225.

After an internal server error, upload_files() could retry a non-seekable file after it had already been consumed. The second multipart request could then carry an empty file and still report success.

Keep the existing retry policy for replayable bodies. If a stream cannot be rewound, surface the original error instead. Non-seekable streams still work on a successful first attempt.

Validated with local HTTPX multipart requests: 13 targeted tests passed, including 6 retry cases. Those 6 also passed from a locally installed wheel and with HTTPX 0.23.0 and Tenacity 8.2.2 on Python 3.12.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

upload_files now retries internal server errors only when every file body can be read again. The retry delay and five-attempt limit remain unchanged. Tests cover replayable and non-seekable bodies, path conflicts, and retry exhaustion.

Changes: Upload retry behavior

Layer / File(s) Summary
Retry eligibility and validation
dagshub/upload/wrapper.py, tests/test_upload_retry.py
The retry predicate checks for an internal server error and confirms that every file body can be reused. Tests cover successful replay, non-seekable streams, path conflicts, and five consecutive server errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: kbolashev

Merge Risk: Minimal · up to b14c5

Uploads no longer retry a non-seekable file stream after it has been consumed, so a retry cannot send an empty file and report success. Replayable bodies keep the existing retry behavior. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: upload retries are blocked for non-replayable file streams. The raw summary confirms that upload_files now retries only when every file body can be rewound, and the te…
Description check Passed The description states the problem (a consumed non-seekable file could be retried and sent empty), the fix (keep retries for replayable bodies and surface the original error otherwise), and the valida…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: upload retries are blocked for non-replayable file streams. The raw summary confirms that upload_files now retries only when every file body can be rewound, and the tests cover this case. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description states the problem (a consumed non-seekable file could be retried and sent empty), the fix (keep retries for replayable bodies and surface the original error otherwise), and the validation performed. It relates directly to the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each stream with care,
Then sends it back through open air.
Bytes and strings can make the trip,
Seekable files can take the skip.
Five tries, then paws rest there.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f987461-ec29-46ce-95a4-224fb69c8472
Commits

Reviewing files that changed from the base of the PR and between 4f7d78a and b14c506.

Files selected for processing: 2

  • dagshub/upload/wrapper.py
  • tests/test_upload_retry.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: CodeRabbit
Additional comments: 2

dagshub/upload/wrapper.py: 1

17-17: LGTM!

Also applies to: 47-61, 350-350, 366-366

tests/test_upload_retry.py: 1

1-107: LGTM!

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