Open
Description
Library name and version
Azure.Search.Documents 11.5.1
Describe the bug
While working on azure search I am trying to capture errors about the need to rebuild the index like:
try
{
res = await _searchIndexClient.CreateOrUpdateIndexAsync(definition, cancellationToken: _sf.CancellationToken);
}
catch (RequestFailedException ex)
{
if (ex.ErrorCode == "OperationNotAllowed" && ex.Status == 400 && ex.Message != null
&& (ex.Message.Contains("CannotDeleteExistingField")
|| ex.Message.Contains("CannotChangeExistingField"))
)
{
throw new UnmodifiableIndexException(definition.Name, ex);
}
throw;
}
I would like to use ex.Data instead of ex.Message.Contains, but Data is always empty.
Looking at the code it looks like Azure.Core.Pipeline.DefaultRequestFailedDetailsParser.TryParseDetails never assign the out parameter out IDictionary<string, string>? data
Expected behavior
RequestFailedException.Data should contains the details of the error
Actual behavior
RequestFailedException.Data is always empty
Reproduction Steps
Create an index on azure search, then modify the code definition so that an RequestFailedException is raised.
The json content will be this:
{
"error": {
"code": "OperationNotAllowed",
"message": "Existing field 'MyField' cannot be changed.",
"details": [
{
"code": "CannotChangeExistingField",
"message": "Existing field 'MyField' cannot be changed."
}
]
}
}
Environment
No response
Metadata
Metadata
Assignees
Labels
This issue points to a problem in the data-plane of the library.Issues that are reported by GitHub users external to the Azure organization.Workflow: This issue needs attention from Azure service team or SDK teamThe issue doesn't require a change to the product in order to be resolved. Most issues start as that