Automatically compute content_hash for uploads#538
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #538 +/- ##
==========================================
+ Coverage 65.14% 65.19% +0.04%
==========================================
Files 31 32 +1
Lines 54902 55001 +99
Branches 3901 3911 +10
==========================================
+ Hits 35767 35858 +91
- Misses 18981 18988 +7
- Partials 154 155 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3cd7088 to
36dcc3c
Compare
cguldner
approved these changes
Jul 13, 2026
36dcc3c to
0cb033e
Compare
Compute and send Dropbox content hashes for byte upload payloads by default. Preserve caller-provided hashes and support opting out. Add unit and live integration coverage for hashing and request verification. Run the complete unit suite in CI and coverage jobs.
0cb033e to
acb5cce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Computes the Dropbox content hash of upload payloads and sends it with the request so the server verifies upload integrity, matching the behavior of dropbox-sdk-go #140.
dropbox/content_hash.py(new) —DropboxContentHasher/StreamHasherfrom dropbox-api-content-hasher, adapted for Python 3 (nosix), plus acontent_hash()helper.auto_content_hashconstructor flag (defaultTrue) to opt out. Preserved acrossclone(),as_user()/as_admin(), andwith_path_root().content_hashfield on upload routes when the caller hasn't supplied one and the payload isbytes. Applies generically to all upload-style routes with acontent_hashfield (files_upload,files_alpha_upload,upload_session_start/append/append_v2/finish).No public API change:
content_hashwas already an optional field on the upload methods; this just fills it in. The logic lives in the hand-written transport so it survives client regeneration, and the caller's argument object is never mutated (a copy is made).Tests
test/unit/test_content_hash.py— hasher algorithm, chunked updates,copy()independence, reuse guard, non-bytes rejection,StreamHasherpassthrough.test/unit/test_dropbox_unit.py— auto on/off, caller-provided hash respected, flag propagation across clone/team/path-root.test/integration/test_dropbox.py::test_upload_auto_content_hash— asserts the server-returnedcontent_hashmatches the locally computed one (end-to-end).Unit suite: 56 passed;
flake8clean.Note
The end-to-end behavior (server accepting and verifying the hash) is only exercised by the integration test, which requires live credentials and runs in CI's Integration job.