Azurite icon indicating copy to clipboard operation
Azurite copied to clipboard

Querying for a binary value fails with HTTP400

Open jezzsantos opened this issue 3 years ago • 4 comments

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

table

Which version of the Azurite was used?

3.16.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

npm

What's the Node.js version?

16.3.1

What problem was encountered?

When making a query to table storage with a binary value in the query, for a row that has binary data, we get a 400 BadRequest, when trying to enumerate the query results.

(this used to work with the Azure Storage Emulator, before moving to Azurite)

Unable to identify the precise code in the SDK that throws this error, but there is no other information, except this stacktrace:

Microsoft.Azure.Cosmos.Table.StorageException: The remote server returned an error: (400) Bad Request.
   at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor.ExecuteAsync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
   at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor.<>c__DisplayClass0_0`1.<ExecuteSync>b__0()
   at Microsoft.Azure.Cosmos.Table.RestExecutor.Utils.RestUtility.RunWithoutSynchronizationContext[T](Func`1 actionToRun)
   at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
   at Microsoft.Azure.Cosmos.Table.RestExecutor.TableRestExecutor.ExecuteQuerySegmented[TResult,TInput](TableQuery`1 query, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver`1 resolver, TableRequestOptions requestOptions, OperationContext operationContext)
   at Microsoft.Azure.Cosmos.Table.TableQuery`1.ExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
   at Microsoft.Azure.Cosmos.Table.TableQuery`1.<>c__DisplayClass42_0.<ExecuteInternal>b__0(TableContinuationToken continuationToken)
   at Microsoft.Azure.Cosmos.Table.CommonUtility.LazyEnumerable[T](Func`2 segmentGenerator, Int64 maxResults)+MoveNext()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Infrastructure.Storage.Azure.AzureTableStorageRepository.QueryPrimaryEntities[TQueryableEntity](String containerName, QueryClause`1 query, RepositoryEntityMetadata metadata) in C:\Projects\endgame\Boost\src\Infrastructure.Storage.Azure\AzureTableStorageRepository.cs:line 192
   at Infrastructure.Storage.Azure.AzureTableStorageRepository.<>c__DisplayClass15_0`1.<Query>b__0() in C:\Projects\endgame\Boost\src\Infrastructure.Storage.Azure\AzureTableStorageRepository.cs:line 138
   at Infrastructure.Storage.RepositoryExtensions.FetchAllIntoMemory[TQueryableEntity](QueryClause`1 query, IRepository repository, RepositoryEntityMetadata metadata, Func`1 getPrimaryEntities, Func`2 getJoinedEntities) in C:\Projects\endgame\Boost\src\Infrastructure.Storage\RepositoryExtensions.cs:line 79
   at Infrastructure.Storage.Azure.AzureTableStorageRepository.Query[TQueryableEntity](String containerName, QueryClause`1 query, RepositoryEntityMetadata metadata) in C:\Projects\endgame\Boost\src\Infrastructure.Storage.Azure\AzureTableStorageRepository.cs:line 137
   at Infrastructure.Storage.IntegrationTests.AnyRepositoryBaseSpec.WhenQueryForBinaryValue_ThenReturnsResult() in C:\Projects\endgame\Boost\src\Infrastructure.Storage.IntegrationTests\AnyRepositoryBaseSpec.cs:line 1497
Request Information
RequestID:14396c28-d9b6-4a31-8940-00816dbddd28
RequestDate:Tue, 01 Mar 2022 06:15:39 GMT
StatusMessage:The remote server returned an error: (400) Bad Request.
ErrorCode:InvalidInput
ErrorMessage:The query condition specified in the request is invalid.
RequestId:14396c28-d9b6-4a31-8940-00816dbddd28
Time:2022-03-01T06:15:39.096Z

Steps to reproduce the issue?

If possible, please provide the debug log using the -d parameter, replacing <pathtodebuglog> with an appropriate path for your OS, or review the instructions for docker containers:

-d "<pathtodebuglog>"

Please be sure to remove any PII or sensitive information before sharing!
The debug log will log raw request headers and bodies, so that we can replay these against Azurite using REST and create tests to validate resolution.

Have you found a mitigation/solution?

No

jezzsantos avatar Mar 01 '22 06:03 jezzsantos

This is the code we are using:

var query = new TableQuery<DynamicTableEntity>();
query = query.Where("ABinaryValue eq X'0102'");

table.ExecuteQuery(query)

jezzsantos avatar Mar 01 '22 06:03 jezzsantos

Table query supporting on binary filter to be investigated.

XiaoningLiu avatar Mar 09 '22 10:03 XiaoningLiu

I'm on this

edwin-huber avatar Apr 27 '22 09:04 edwin-huber

Hey @edwin-huber, this fix is not yet released for Azurite, correct? (my test still seems to still fail on 3.18.0)

jezzsantos avatar Jul 21 '22 05:07 jezzsantos

Hi Sorry for the delay in response. The fix is being worked on, it has required a re-write of the query parser and a lot of refactoring!

edwin-huber avatar Nov 02 '22 17:11 edwin-huber

Thx @edwin-huber do you know which release to expect this fix in?

jezzsantos avatar Dec 02 '22 19:12 jezzsantos