Azure / Azure/Azurite

500 Error: XmlException: Root element is missing

Open
#1,687 8 comments 0 reactions 1 assignee Claimed by @blueww View on GitHub
question queue-storage Visual Studio
Dominant language
TypeScript
Stars
2.3k
Forks
393
Avg merge
1d 20h
Merged PRs (30d)
36

Description

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

### Which version of the Azurite was used?
3.16.0

### Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
Visual Studio 2022 17.2.0 built-in

### What's the Node.js version?
14.17.3

### What problem was encountered?
While attempting to run QueueClient.SendMessageAsync(b64), the request hangs for ~10 seconds and then throws 500 Internal Server Error.

```
var created = _queueClient.CreateIfNotExists();
if (_queueClient.Exists())
{
if (created != null)
{
_logger.LogInformation($"Queue created: '{_queueClient.Name}'");
}
else
{
_logger.LogInformation($"Queue found: '{_queueClient.Name}'");
}

// queue requires a base64 string
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(reportId);
var b64 = Convert.ToBase64String(plainTextBytes);

await _queueClient.SendMessageAsync(b64);
}
else
{
_logger.LogError($"Unable to find or create queue: '{_queueClient.Name}'");
return;
}
```

The exception that I recieve is
```
System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at Azure.Storage.Queues.QueueRestClient.Messages.EnqueueAsync_CreateResponse(ClientDiagnostics clientDiagnostics, Response response)
at Azure.Storage.Queues.QueueRestClient.Messages.EnqueueAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri resourceUri, QueueSendMessage message, String version, Nullable`1 visibilitytimeout, Nullable`1 messageTimeToLive, Nullable`1 timeout, String requestId, Boolean async, String operationName, CancellationToken cancellationToken)
at Azure.Storage.Queues.QueueClient.SendMessageInternal(String messageText, Nullable`1 visibilityTimeout, Nullable`1 timeToLive, Boolean async, CancellationToken cancellationToken)
at Azure.Storage.Queues.QueueClient.SendMessageAsync(String messageText, Nullable`1 visibilityTimeout, Nullable`1 timeToLive, CancellationToken cancellationToken)
at Azure.Storage.Queues.QueueClient.SendMessageAsync(String messageText)
```

My Queue folder is currently empty but it has definitely been recieving messages a few days ago, so it seems like something deleted the queue file. The __azurite_db_queue__.json still has a reference to the queue I'm trying to write to.

I'm not sure if this is related, but I also still regularly encounter this issue:
https://github.com/Azure/Azurite/issues/1492

### Steps to reproduce the issue?
Intermittent

### Debug logs
```
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: QueueStorageContextMiddleware: Account=devstoreaccount1 Queue=recording-import-jobs Message=messages MessageId=undefined
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 verbose: DispatchMiddleware: Dispatching request...
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: DispatchMiddleware: Operation=Messages_Enqueue
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: QueueSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: QueueSharedKeyAuthenticator:validate() [STRING TO SIGN]:"POST\n\n\n88\n\napplication/xml\n\n\n\n\n\n\nx-ms-client-request-id:f6f23474-5cbc-4b77-bb53-0d44cea0941c\nx-ms-date:Tue, 20 Sep 2022 00:39:40 GMT\nx-ms-return-client-request-id:true\nx-ms-version:2018-11-09\n/devstoreaccount1/devstoreaccount1/recording-import-jobs/messages"
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: QueueSharedKeyAuthenticator:validate() Calculated authentication header based on key1: devstoreaccount1:+BhqAybFO7EW/eqMnRSfR1l8TGtfk+IETmEp7qnzWd4=
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: QueueSharedKeyAuthenticator:validate() Signature 1 matched.
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 verbose: DeserializerMiddleware: Start deserializing...
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: deserialize(): Raw request body string is (removed all empty characters) bXhyZnUwR3VRa0tZWFlQdVc1SUctUQ==
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: HandlerMiddleware: DeserializedParameters={"options":{"requestId":"f6f23474-5cbc-4b77-bb53-0d44cea0941c"},"version":"2018-11-09","queueMessage":{"messageText":"bXhyZnUwR3VRa0tZWFlQdVc1SUctUQ=="},"body":"ReadableStream"}
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: OperationQueue.operate() Schedule incoming job 7e2926a6-5ac5-44ff-a314-4d14e1426b5b
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:1 operations.length:1
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: FSExtentStore:appendExtent() Select extent from idle location for extent append operation. LocationId:0 extentId:c297fef4-6975-48e5-8ec0-d52a8d302e1b offset:0 MAX_EXTENT_SIZE:67108864
2022-09-20T00:39:40.842Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: FSExtentStore:appendExtent() Get fd:undefined for extent:c297fef4-6975-48e5-8ec0-d52a8d302e1b from cache.
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: OperationQueue.operate() Job 7e2926a6-5ac5-44ff-a314-4d14e1426b5b error, reject.
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 error: ErrorMiddleware: Received an error, fill error information to HTTP response
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 error: ErrorMiddleware: ErrorName=Error ErrorMessage=ENOENT: no such file or directory, open 'C:\Users\***\AppData\Local\Temp\Azurite\__queuestorage__\c297fef4-6975-48e5-8ec0-d52a8d302e1b' ErrorStack="Error: ENOENT: no such file or directory, open 'C:\\Users\\***\\AppData\\Local\\Temp\\Azurite\\__queuestorage__\\c297fef4-6975-48e5-8ec0-d52a8d302e1b'"
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 error: ErrorMiddleware: Set HTTP code: 500
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 info: EndMiddleware: End response. TotalTimeInMS=2 StatusCode=500 StatusMessage=undefined Headers={"server":"Azurite-Queue/3.16.0"}
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:1 operations.length:0
2022-09-20T00:39:40.843Z b42cb624-6bb3-4582-ad42-44bd425f7f28 debug: OperationQueue:execute() return. Operation.length === 0
```

### Have you found a mitigation/solution?
Restarting my PC fixed the queue issue, but it doesn't work for the issue when it happens with Blobs.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.