azure-sdk-for-java
azure-sdk-for-java copied to clipboard
com.azure.core.exception.HttpResponseException: Deserialization Failed.
I am using azure-storage-blob v12.14.4 dependency to get storage blobs data. It works but some times it gets an error:
com.azure.core.exception.HttpResponseException: Deserialization Failed.
This error log is very long, just I want to mention only last a few rows. Here was written like that:
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (byte[])"<?xml version="1.0" encoding="utf-8"?>
<StorageServiceProperties><Cors/><DeleteRetentionPolicy><Enabled>false</Enabled><AllowPermanentDelete>false</AllowPermanentDelete></DeleteRetentionPolicy></StorageServiceProperties>"; line: 1, column: 5]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:735)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:659)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2737)
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:4762)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4668)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3724)
at com.azure.core.implementation.jackson.ObjectMapperShim.readValue(ObjectMapperShim.java:215)
at com.azure.core.util.serializer.JacksonAdapter.lambda$deserialize$8(JacksonAdapter.java:224)
at com.azure.core.util.serializer.JacksonAdapter.useAccessHelper(JacksonAdapter.java:264)
at com.azure.core.util.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:222)
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.deserializeBody(HttpResponseBodyDecoder.java:169)
at com.azure.core.implementation.serializer.HttpResponseBodyDecoder.lambda$decodeByteArray$1(HttpResponseBodyDecoder.java:105)
It seams to Azure SDK returns XML data as a result, which were expecting JSON. It's happens not all request, maybe it is occurred once from dozens of request.
Code Snippet I put my code on the below:
String blobServiceURL = String.format("https://%s.blob.core.windows.net", storageAccount.name());
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.credential(clientSecretCredential)
.endpoint(blobServiceURL)
.buildClient();
BlobServiceProperties blobServiceProperties = blobServiceClient.getProperties();
return transformProperties(blobServiceProperties);
I've been looking for a few days, but I found nothing to solve this problem or related post.
Setup (please complete the following information):
- OS: Linux
- Library/Libraries: com.azure:azure-storage-blob:12.14.4
- Java version: 11
- Frameworks: Spring Boot
@rickle-msft could you please take a look?
@ulugbekrozimboyev Thank you for opening this issue. If it's not sensitive, can you share the details of the cors rules you're setting on the account so I can try to reproduce the setup more closely?
@rickle-msft which kind of settings you mean ?
@ulugbekrozimboyev The line of xml that comes up in the error string suggested to me that maybe you were setting Cors Rules. But perhaps that is not the case?
@alzimmermsft Have you seen this deserialization error before?
@rickle-msft I haven't seen an error like this before.
@ulugbekrozimboyev you mention this occurs semi-frequently, would it be possible for you to enable network logging and include some information from the network log, most importantly Content-Type
. The quickest way to enable network logging is setting the environment variables AZURE_LOG_LEVEL: verbose
and AZURE_HTTP_LOG_DETAIL_LEVEL: headers
, if you're using a logging framework based on slf4j you don't need to set AZURE_LOG_LEVEL
but instead need to allow com.azure.*
to log at the debug/verbose level.
Content-Type
determines how the response body is deserialized, and to me it seems that this may be getting mangled somewhere leading the response to be handled as JSON instead of application/xml
that the REST API returns, https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties#sample-request-and-response.
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!