Repository navigation
python(feat): send and expose the artifact file SHA-256 - #870
Open
alexluck-sift wants to merge 6 commits into
Open
alexluck-sift wants to merge 6 commits into
alexluck-sift wants to merge 6 commits into
Conversation
Contributor
|
Python docs preview: https://sift-stack.github.io/sift/python/pr-870/ Deployed from |
alexluck-sift
force-pushed
the
al/python/feat/artifact-file-sha256
branch
from
November 5, 2026 00:09
d72a021 to
a19112c
Compare
alexluck-sift
marked this pull request as ready for review
November 5, 2026 00:32
wei-sift
reviewed
Nov 6, 2026
|
|
||
| def __init__(self, file: BinaryIO): | ||
| self._file = file | ||
| start = file.tell() |
Contributor
There was a problem hiding this comment.
A buffer that was written to or already uploaded once is left at its end, so it now uploads as an empty file with no error. Can we seek(0) before hashing and uploading so the whole file is always sent?
Collaborator
Author
There was a problem hiding this comment.
Good catch, fixed in 826aa89. A file object now uploads whole from its start, whatever its position, and the hash covers the whole file. Added a test for a written BytesIO that wasn't rewound, plus open files and buffers left mid-file or at the end.
This branch has not been deployed
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
Artifact uploads now send the SHA-256 of the file, and
ArtifactVersion.file_sha256returns it. A caller can compare a local file with the latest version's hash and skip an upload when the file has not changed.ArtifactVersion.file_sha256: the lowercase hex SHA-256 that the upload sent, orNonefor a version uploaded without oneArtifactsAPI.createandArtifactsAPI.updatesend the hash as thesha256form field of the upload. The hash covers the whole file: a path,bytes, or a seekable file object.UploadLowLevelClient.upload_attachmenttakessha256=Trueto hash the file in 1 MiB chunks and then seek back to the start. Only the artifact path sets it, so other attachment uploads do not read their files a second time.Fix: every upload now seeks a file object to its start and sends the whole file. Before,
MultipartEncodersent anio.BytesIOwhole fromgetvalue()but an open file only from its current position, so an open file that was already read uploaded empty. This keeps the hash and the uploaded bytes the same.Verification
io.BytesIOthat was written to and not rewound. For both versions,file_sha256matched the local SHA-256 of the bytes sent, and the downloaded file matched them byte for byte.