opensearch-net icon indicating copy to clipboard operation
opensearch-net copied to clipboard

[BUG] Deserialization Cannot Handle Types which Implement IDisposable (JsonDocument)

Open JCKortlang opened this issue 7 months ago • 0 comments

What is the bug?

Deserialization Cannot Handle Types which Implement IDisposable (JsonDocument)

ObjectDisposedException: Cannot access a disposed object.
Object name: 'JsonDocument'.

How can one reproduce the bug?

using System.Text.Json.Nodes
var response =  await openSearchClient.SearchAsync<JsonDocument>(searchRequest);
return response.Hits.Select(hit => hit.Source.Id).ToList(); //Use the disposable object

What is the expected behavior?

I expect to be able to deserialize to standard .NET Json abstractions. I expect to be able to deserialize to disposable values.

What is your host/environment?

MacOS 13.6.7 (22G720)

Do you have any screenshots?

No

Do you have any additional context?

I am attempting to deserialize a request to an index alias that contains multiple types. Since the Search interface does not support this, I need to deserialize the response to a more generic type. Ideally one of the standard and existing Json abstractions.

JCKortlang avatar Jul 23 '24 00:07 JCKortlang