Skip to content

[BUG][Blob Storage] 0 byte blobs are uploaded if incorrect length is specified #13092

Closed
@SukruthKS

Description

Describe the bug
With the new beta version of the blob storage SDK 12.8.0-beta.1, zero length blobs are uploaded if the specified blob size does not match with the input stream. This can mislead applications into believing that blobs have been uploaded correctly. The previous version of the SDK threw an error instead of uploading the blob.

Exception or Stack Trace
NA

To Reproduce
Sample code to repro this:

final String containerName = "<container_name>";
final String blobName = "<blob_name>";

final String content = "Hello World!";
final byte[] contentBytes = content.getBytes();

try(InputStream inStream = new ByteArrayInputStream(contentBytes))
{
    BlobClient blobClient = serviceClient.getBlobContainerClient(containerName)
        .getBlobClient(blobName);

    blobClient.upload(inStream, contentBytes.length + 10); // Incorrect length

    BlobProperties properties = blobClient.getProperties();
    System.out.println("Blob size: " + properties.getBlobSize());
}

Output with 12.8.0-beta.1:

Blob size: 0

Output with 12.7.0:

Exception in thread "main" com.azure.core.exception.UnexpectedLengthException: Request body emitted 12 bytes, less than the expected 22 bytes.

Code Snippet
Added above

Expected behavior
Either the SDK should throw an error if the lengths did not match or treat the input stream as source of truth and upload the content available from the stream.

Screenshots
NA

Setup (please complete the following information):

  • OS: Linux
  • IDE : IntelliJ
  • Version of the Library used: 12.8.0-beta.1

Additional context
NA

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.pillar-reliabilityThe issue is related to reliability, one of our core engineering pillars. (includes stress testing)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions