Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Azure search - ObjectDisposedException thrown instead of IndexBatchException when merging index batch #6910

Closed
cwi3310 opened this issue Jul 12, 2019 · 4 comments · Fixed by #7011
Assignees
Labels

Comments

@cwi3310
Copy link

cwi3310 commented Jul 12, 2019

Describe the bug
Using Net Framework 4.7.1, when merging documents with key not present in azure search index, a ObjectDisposedException is thrown instead of IndexBatchException.

Exception or Stack Trace
Cannot access a disposed object. Object name: 'System.Net.Http.StringContent'
at System.Net.Http.HttpContent.CheckDisposed()
at System.Net.Http.HttpContent.ReadAsStringAsync()
at Microsoft.Azure.Search.DocumentsOperations.d__19`1.MoveNext()

To Reproduce
Steps to reproduce the behavior:

  1. Create a batch of document complying to an azure search index model but with the key missing in index
  2. Merge the batch to the index and catch the exception thrown
    The exception thrown should be ObjectDisposedException instead of IndexBatchException

Code Snippet

var searchClient = new SearchServiceClient(searchName, new SearchCredentials(searchKey));
var documents = new Model[]
{
    new Model
    {
         Id = "abcd",
         Description = "Key Id not present in index"
    },
};
var batch = IndexBatch.Merge(documents);

try
{
    searchClient.Indexes.GetClient(indexName).Documents.Index(batch);
    Console.WriteLine("\t> Batch successfully run");
}
catch (IndexBatchException e)
{
    Console.WriteLine("\t> Batch failed with expected exception");
}
catch (ObjectDisposedException ex)
{
    Console.WriteLine("\t> Batch failed with unexpected exception");
}

Expected behavior
We expect the IndexBatchException to be thrown instead of ObjectDisposedException

Setup:

  • OS: Windows
  • IDE : Visual Studio 2019
  • Microsoft.Azure.Search.Data 9.0.1
    .Net Framework 4.7.1

Additional context
The problem doesn't seems to appears in .Net Core.

@triage-new-issues triage-new-issues bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jul 12, 2019
@brjohnstmsft brjohnstmsft self-assigned this Jul 14, 2019
@triage-new-issues triage-new-issues bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jul 14, 2019
@brjohnstmsft
Copy link
Member

@cwi3310 Thanks for reporting this. We'll investigate.

@brjohnstmsft
Copy link
Member

@arv100kri is investigating

@arv100kri
Copy link
Member

@cwi3310 - Thanks for reporting the bug, I've checked in a pull request that will fix this.
I'll update this thread, sometime next week once we make a release of a new nuget package.

@arv100kri
Copy link
Member

We have a new nuget package released (v 9.1.0) that should contain the fixes from the aforementioned PR: https://www.nuget.org/packages/Microsoft.Azure.Search/

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants