From a1a6647ea7dce4e91ffe043e9cf12a1384456893 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 2 Aug 2016 12:15:30 -0400 Subject: [PATCH] Add additional logs for invalid blob upload Fixes #1668 --- endpoints/v2/blob.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index 5e6109665..3136b4580 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -284,7 +284,9 @@ def _finish_upload(namespace_name, repo_name, upload_obj, expected_digest): # Verify that the digest's SHA matches that of the uploaded data. computed_digest = digest_tools.sha256_digest_from_hashlib(upload_obj.sha_state) if not digest_tools.digests_equal(computed_digest, expected_digest): - raise BlobUploadInvalid() + logger.error('Digest mismatch for upload %s: Expected digest %s, found digest %s', + upload_obj.uuid, expected_digest, computed_digest) + raise BlobUploadInvalid(detail={'reason': 'Digest mismatch on uploaded blob'}) final_blob_location = digest_tools.content_path(expected_digest) @@ -353,7 +355,7 @@ def upload_chunk(namespace_name, repo_name, upload_uuid): def monolithic_upload_or_last_chunk(namespace_name, repo_name, upload_uuid): digest = request.args.get('digest', None) if digest is None: - raise BlobUploadInvalid() + raise BlobUploadInvalid(detail={'reason': 'Missing digest arg on monolithic upload'}) blob_upload, upload_error = _upload_chunk(namespace_name, repo_name, upload_uuid) blob_upload.save()