Azure / azure-storage-java

Microsoft Azure Storage Library for Java
https://docs.microsoft.com/en-us/java/api/overview/azure/storage
MIT License
189 stars 165 forks source link

Stage 11th block in blockBlobClient.stageBlock return 400 One of the request inputs is not valid. #584

Open alicenicieja opened 1 year ago

alicenicieja commented 1 year ago

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the SDK was used?

v12.19.1

What problem was encountered?

When I am trying to stageBlock 11th block I am receiving 400 One of the request inputs is not valid.

I observed that this is related to the block id. This is the id I am creating:

String base64BlockId = Base64.getEncoder().encodeToString(String.valueOf(counter).getBytes());

and counter is starting from 0. On 11th I had an error (with number of 10 counting from 0). Based on the documentation I see that all ids should have the same length and each base64BlockId for 0 and 10 has exactly the same length, but before encoding of course the length is bigger for 10 than for 0. And as a result I can commit only less than 11 stages. Can you please point out a problem ?

This is my code snippet:

    String base64BlockId = Base64.getEncoder().encodeToString(String.valueOf(counter).getBytes());
    blockBlobClient.stageBlock(base64BlockId, new ByteArrayInputStream(bytes), bytes.length);

I tried with id pattern like 001 but then I received this error on a first stageBlock call.