Azurite icon indicating copy to clipboard operation
Azurite copied to clipboard

BUG: com.azure.core.exception.HttpResponseException: Deserialization Failed

Open heurisctics123 opened this issue 3 years ago • 6 comments

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

*Which version of the Azurite was used? Docker / 3.18.0

*Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension) DockerHub: mcr.microsoft.com

*What's the Node.js version? The one in the provided docker container

*What problem was encountered? Edit: There is no problem with my code because if I test it towards a real Azure system it works.

I have been able to to run a local container of Azure Blob storage. Most of the time it works(when I upload images) but it fails when I provide other types of data. I get exactly the following error:

Blob operation error on blob: 'reports/08191407-a4d4-4c86-9f3c-45a02b8c93ec' com.azure.core.exception.HttpResponseException: Deserialization Failed. at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.decodeByteArray(HttpResponseBodyDecoder.java:92) at com.azure.core.implementation.serializer.HttpResponseDecoder$HttpDecodedResponse.getDecodedBody(HttpResponseDecoder.java:93) at reactor.core.publisher.Mono.lambda$mapNotNull$28(Mono.java:3429) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:176) at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2398) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.request(FluxHandleFuseable.java:257) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2194) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2068) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onSubscribe(FluxHandleFuseable.java:161) at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55) at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157) at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) at reactor.core.publisher.FluxDoOnEach$DoOnEachSubscriber.onNext(FluxDoOnEach.java:173) at reactor.core.publisher.FluxDoOnEach$DoOnEachFuseableSubscriber.onNext(FluxDoOnEach.java:281) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) at reactor.core.publisher.FluxDelaySubscription$DelaySubscriptionMainSubscriber.onNext(FluxDelaySubscription.java:189) at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99) at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99) at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.onNext(FluxTimeout.java:180) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:292) at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99) at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.onNext(FluxRetryWhen.java:174) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2664) at reactor.core.publisher.MonoSingle$SingleSubscriber.onComplete(MonoSingle.java:180) at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onComplete(MonoFlatMapMany.java:260) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onComplete(FluxDoFinally.java:128) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1817) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160) at reactor.core.publisher.FluxHandle$HandleSubscriber.onComplete(FluxHandle.java:220) at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onComplete(FluxMap.java:275) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419) at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473) at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:703) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'PK o': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') ?u???\u0019+??a\u007Fi]??\u0012?d?F?_???6P?\u0002v??i?q?a?\u001C\u0013\u0017\u0006x\u0015???\u007F??\u00010?\u001E\u0000?\u001BJ\u0006??,?t??\u0019l?\u0013???/?~??Dj8I? ?\u007F?I?PJ?T?G?mkHr+???R&v\u001E?^Hk?\q?b;W????\u0015'-?s???)~???>?o?\u0014\u007FO)n? h?.?\u0012???'??\u001BC\u0003? I#\u0002?&i\u0007?#\u0013?\u0000\u001E???nxg?/??H???>??f?Y!\u000Er"[truncated 920346 bytes]; line: 1, column: 13] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:745) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidToken(UTF8StreamJsonParser.java:3635) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2734) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:902) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:794) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4761) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4667) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3723) at com.azure.core.implementation.jackson.ObjectMapperShim.readValue(ObjectMapperShim.java:224) at com.azure.core.util.serializer.JacksonAdapter.lambda$deserialize$8(JacksonAdapter.java:225) at com.azure.core.util.serializer.JacksonAdapter.useAccessHelper(JacksonAdapter.java:271) at com.azure.core.util.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:223) at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.deserializeBody(HttpResponseBodyDecoder.java:145) at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.decodeByteArray(HttpResponseBodyDecoder.java:86) ... 81 common frames omitted

heurisctics123 avatar Jul 21 '22 14:07 heurisctics123

I dont know but it might be related to the following issue.

heurisctics123 avatar Jul 21 '22 14:07 heurisctics123

@heurisctics123

It looks the error happens on the client side. The related issue from you looks also fixed by a client side change. Not sure if you already use the latest client SDK. If so, you might can contact sdk team like the related issue to see if they have any idea.

blueww avatar Jul 22 '22 02:07 blueww

It is quite weird because If I run my code in a real Azure system I don't get any error so I don't see why the error should happen on the client side. I am not quite sure how similiar is the behaviour of this container to the behaviour of the real system.

heurisctics123 avatar Jul 22 '22 05:07 heurisctics123

@heurisctics123

With only client exception, we don't have enough information to investigate this. Would you please:

  1. Contact the Client team to see if they have any idea. (You can just file an issue as the one in your before comments)
  2. Give the detail repro steps for this issue.
  3. Give the Azurite debug log when the issue happen.

blueww avatar Jul 29 '22 09:07 blueww

Apparently, the root cause is related to the following issue:
https://github.com/Azure/Azurite/issues/647 So please give support for blob tag feature. No proper local testing can be done without it.

Edit: Our team lead has clarified in more details when the error happens in the comment below @blueww . Hopefully you will prioritize this issue :D

heurisctics123 avatar Oct 12 '22 06:10 heurisctics123

@heurisctics123 Thanks for the update!

How do you get the root cause is Azurite still not support Blob Tag? Which scenario do you use blob tag (which rest API, parameter)? And why client failed since blob tag not support (does client fail on call some blob tag specific API, send blob tag related parameter, or expect some server responds with blob tag specific properties)?

Ask this since we need this information to prioritize the blob tag work, and design blob tag implemetaion in Azurite.

blueww avatar Oct 12 '22 07:10 blueww

The issue happens when we call the "getTags" method on the client (java sdk; class: BlobAsyncClientBase; method: getTags). This translates to an http request like: https://host/container/blobname?comp=tags

The relevant part is that the comp=tags part gets added.

Azure Storage Cloud returns XML in the http response body (which represents the tags), which is what the client sdk expects and tries to parse.

Azurite seems to ignore comp=tags parameter and returns the binary. Client sdk tries to parse that and fails as it is neither valid XMl nor JSON.

nwei-mc avatar Oct 13 '22 07:10 nwei-mc

@nwei-mc Thanks for the update!

From your description, I get this is caused by GetTag API still not support by Azurite, so Azurite parse it to another API and ignore "comp=tags".

blueww avatar Oct 13 '22 08:10 blueww

Hi Team, I am getting the same 'Deserialization error' but on invoke of comp=list My Scenario: Trying to connect to a EVentHub and provide a BlobStorageAccount as Checkpointstore( NOTE: no blobs present ) . After the invocation of eventProcessorClient.start() I get the error WARN com.azure.messaging.eventhubs.PartitionBasedLoadBalancer - Load balancing for event processor failed. Deserialization Failed.

On investigating what I could figure out is : Every time the PartitionLoadBalancer tries to invoke the blobAzyncClient.listBlobs internally it tries to make a Rest API call GET https://t/?restype=container&comp=list&prefix=///ownership/&include=metadata Repose 'Content-Type' is 'application/XML' but
we get a warning message on the console WARN com.azure.core.util.serializer.SerializerEncoding - 'Content-Type' not found. Returning default encoding: JSON , and after that I can see deserialization fail error.

11:02:32.007 [reactor-http-kqueue-1] WARN com.azure.messaging.eventhubs.PartitionBasedLoadBalancer - Load balancing for event processor failed. Deserialization Failed. com.azure.core.exception.HttpResponseException: Deserialization Failed. at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.decodeByteArray(HttpResponseBodyDecoder.java:81) at com.azure.core.implementation.serializer.HttpResponseDecoder$HttpDecodedResponse.getDecodedBody(HttpResponseDecoder.java:93) at reactor.core.publisher.Mono.lambda$mapNotNull$28(Mono.java:3432) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:169) at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2398) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.request(FluxHandleFuseable.java:250) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:169) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2194) at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2068) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onSubscribe(FluxHandleFuseable.java:154)

azure-storage-blob : 12.20.1 version azure-core : 1.35.0 jackson-core: 2.13.2

sup16013 avatar Jan 25 '23 17:01 sup16013

@sup16013

Would you please give the Azurite debug log and Azurite version for this issue? And if this is not the same issue as the origin issue, please open a new issue for it and follow up the issue template, then we can get most of the information needed for investigation.

blueww avatar Jan 30 '23 03:01 blueww

Hello, I am using Azurite latest version. I am getting the same error when calling getTags() method of BlobClient class. Is there any solution for it?

DivyansMahansaria avatar Feb 06 '23 13:02 DivyansMahansaria

@DivyansMahansaria Currently Blob Index Tag feature is still not supported by Azurite. The feature is in our plan, and will update this issue when this is implemented.

Before the feature is supported by Azurite, would you please don't call Tag related API like GetTags() to Azurite, or there might be unexpected result. Thanks for your understanding!

blueww avatar Feb 07 '23 03:02 blueww

@sup16013

Would you please give the Azurite debug log and Azurite version for this issue? And if this is not the same issue as the origin issue, please open a new issue for it and follow up the issue template, then we can get most of the information needed for investigation. @blueww Sorry you can ignore my comment. As my error was caused from my Java Client using AzureJava sdk API and not Azurite. I have resolved the error by switching to azure-core : 1.34.0 instead of azure-core : 1.35.0. deserialize method in 1.35 was creating issues . Thanks !!!

sup16013 avatar Feb 07 '23 03:02 sup16013

Facing same issue while using azure-core 1.35.0. it is create issue while i try to create queue using JAVA-SDK. com.azure.core.exception.HttpResponseException: Deserialization Failed.

YogeshwarPrajapatiTR avatar Mar 01 '23 14:03 YogeshwarPrajapatiTR

Facing same issue using the Java libraries of azure-core 1.36.0, azure-messaging-eventhubs-checkpointstore-blob 1.16.3, azure-core-amqp 2.8.2, and azure-messaging-event-hubs 5.15.2 . We are using Event hubs with checkpointing. The load-balancing code is retrieving my checkpoint ownership ( which is in XML) but the code is treating it as JSON so it is getting a JsonProcessingException hence "Deserialization Failed". We do see the following error :

[co.az.co.ut.se.SerializerEncoding] (reactor-http-epoll-1) 'Content-Type' not found. Returning default encoding: JSON

Perhaps content type from the http response has no Content-type header due to a code change or the default changed in the SerializerEncoding class? I will try azure.core 1.34.0 and corresponding versions for the other packages and hope it works.

bronzegod3 avatar Mar 01 '23 20:03 bronzegod3

@bronzegod3

In the blob rest API doc, it says

The Content-MD5 element appears in the response body only if it has been set on the blob using version 2009-09-19 or later.

I have also checked with the team owns Storage API, and they confirmed contentMD5 is optional. So this is expected contentMD5 is optional and not always return from server.

So this is a bug in the libraries you are using. They expect an optional property "contentMD5" always be returned from server, which is not correct.

blueww avatar Mar 02 '23 09:03 blueww

Thanks for the reply but I think you answered a question from another bug report here.; I have no idea what you are talking about. The issue here was that the checkpoint ownership information was returned to the library as XML but the library was interpreting it as JSON so it got a deserialization error. While debugging I saw the XML data and confirmed this.

bronzegod3 avatar Mar 03 '23 16:03 bronzegod3

@bronzegod3 Sorry for the confusing!

From your issue, it looks 'Content-Type' is missing from responds. But I can't repro this issue when list blob with Azurite 3.22.0.

Would you please share:

  1. Azurite version
  2. Which Storage API responds caused "Deserialization Failed"?
  3. Azurite debug log

BTW, this looks a different issue than the original one (the orignal one is for blob tag not support.) It would be better if you could open a new issue and follow the issue template to give the above information needed for investigation.

blueww avatar Mar 06 '23 02:03 blueww

You're right, it does seem my issue is different and I apologize for reporting my issue here.

bronzegod3 avatar Mar 09 '23 15:03 bronzegod3