Skip to content

Support unknown file sizes in streaming encryption to fix SFTP timeouts#32

Merged
VulcanoSoftware merged 1 commit into
mainfrom
fix-sftp-streaming-upload-timeout-14649539708529037240
Jul 7, 2026
Merged

Support unknown file sizes in streaming encryption to fix SFTP timeouts#32
VulcanoSoftware merged 1 commit into
mainfrom
fix-sftp-streaming-upload-timeout-14649539708529037240

Conversation

@VulcanoSoftware

Copy link
Copy Markdown
Owner

The issue was that the encryption layer (EncryptingFileMessage and ciphertext_size_for_plaintext) raised a ValueError when plaintext_size was -1, which occurs when an SFTP client starts an upload without specifying the file size. This caused the upload task to fail immediately, leading to connection timeouts on the client side.

I modified the cryptographic arithmetic and the streaming wrapper to support unknown file sizes by treating -1 as a sentinel for an infinite/unknown stream. I also added comprehensive tests to verify that these "size-less" streams can be encrypted and decrypted correctly.


PR created automatically by Jules for task 14649539708529037240 started by @VulcanoSoftware

Updated the encryption layer to correctly handle plaintext streams with
unknown sizes (indicated by -1). This is required for SFTP clients that
start uploads without declaring the total file size upfront.

Changes:
- dcfs/crypto/cipher.py: ciphertext_size_for_plaintext now returns -1
  instead of raising ValueError when input is -1.
- dcfs/crypto/stream.py: EncryptingFileMessage updated to skip size-based
  capping and correctly read from inner streams when size is -1.
- tests/test_crypto/test_repository.py: added integration test for
  streaming uploads with unknown size and updated fake repository.
- tests/test_crypto/test_cipher.py: added unit test for unknown size
  arithmetic.

Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@VulcanoSoftware VulcanoSoftware marked this pull request as ready for review July 7, 2026 06:26
@VulcanoSoftware VulcanoSoftware merged commit 1592949 into main Jul 7, 2026
1 check passed
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