Skip to content

Conversation

@tomholford
Copy link

@tomholford tomholford commented Jan 6, 2026

Summary

Implement shouldRetry, replacing an always false stub

Problem

The shouldRetry function was a stub returning false unconditionally, preventing the pacer from retrying transient errors. Users see failures like:

  • 422 POST .../storage/blocks: Operation failed: Please retry (Code=200501)

These should be automatically retried but aren't.

See also:

https://forum.rclone.org/t/rclone-uploads-failing-to-proton-drive/52545

Changes

  • Implement proper shouldRetry following pattern from other backends (box, dropbox)
  • Check context cancellation via fserrors.ContextError
  • Retry storage block errors (Code=200501)
  • Retry rate limiting (429) and server errors (5xx)
  • Fall back to fserrors.ShouldRetry for network-level errors

Test plan

  • golangci-lint passes
  • go build and go test pass
  • Manual test: upload file to Proton Drive (see below)

Manual test results

Tested with real Proton Drive account. The fix correctly detects and retries Code=200501 errors:

DEBUG : Retrying storage block error: 422 POST .../storage/blocks: Operation failed: Please retry (Code=200501, Status=422)
DEBUG : pacer: low level retry 1/10 (error 422 POST ...)
DEBUG : pacer: Rate limited, increasing sleep to 20ms

Note: Uploads still fail due to a separate orphaned draft issue (Code=2500/2501) in the upstream Proton-API-Bridge library. This is a known limitation tracked at henrybear327/Proton-API-Bridge#16 and requires ClientUID support to resolve. The shouldRetry fix in this PR works as intended.

Notes

Reviewed shouldRetry implementations across other backends (swift, dropbox, ftp, putio, filescom, box). This implementation follows the established pattern: context check first, backend-specific error detection, then fallback to fserrors.ShouldRetry. String-based error matching mirrors dropbox's approach, which is appropriate when the underlying SDK doesn't expose typed errors.

Fix broken shouldRetry function that always returned false, completely
disabling the pacer's retry mechanism.

- Check context cancellation via fserrors.ContextError
- Retry transient storage block errors (Code=200501)
- Retry rate limiting (429) and server errors (5xx)
- Fall back to fserrors.ShouldRetry for network-level errors
Add table-driven tests covering:
- nil error handling
- context cancellation
- Proton-specific retriable errors (Code=200501)
- rate limiting (429) and server errors (5xx)
- non-retriable client errors (400, 404)
@ncw
Copy link
Member

ncw commented Jan 6, 2026

Looking good so far - carry on please :-)

@tomholford tomholford marked this pull request as ready for review January 7, 2026 00:03
@tomholford
Copy link
Author

Looking good so far - carry on please :-)

Thank you, just did a manual test and it worked as expected. Marked as ready for review 🤞 Next going to take a crack at the upstream issue in the Proton API Bridge

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.

2 participants