Deserialization issues with GetAsync<T>

Description

I'm noticing some odd behavior when trying to do GetAsync<T> where T is a class I've specified. I would have expected that GetAsync<T> would have returned the document I've inserted, but it appears that it's returning the document within a document, with a field name of "". 

 

Here's some sample code illustrating the issue, plus a workaround: 

 

var connString = "couchbase://10.0.0.220"; var options = new ClusterOptions(); options.WithBucket("bugtest") .WithCredentials("Administrator", "danger") .WithServers(connString); var cluster = new Cluster(connString, options); var bucketResult = cluster.BucketAsync("bugtest"); bucketResult.Wait(); var collection = bucketResult.Result.DefaultCollection(); var testData = new TestData() { StringTest = "test", IntTest = Int32.MaxValue, DictTest = new Dictionary<string, int>(){ {"key1", 1}, {"key2", 2}, {"key3", 3} } }; var key = "test:mydoc"; collection.InsertAsync(key, testData); var getResult = collection.GetAsync(key, options => { }); getResult.Wait(); var r = getResult.Result; var badResult = r.ContentAs<TestData>(); // this should return the object we inserted, but it does not /* It looks like it's returning a document that looks like this: {"" : {<the actual document content>}} */ //this is the workaround for Get var correctResult = (JToken)(r.ContentAs<dynamic>()[""]); var cr = (TestData)correctResult.ToObject(typeof(TestData)); //this returns what I would have expected.

Environment

.Net Core 3.0.1

Gerrit Reviews

None

Release Notes Description

None

Activity

Show:

Michael Nitschinger March 15, 2020 at 5:56 AM

Added integration test, not seeing it anymore on 3.0.0

Michael Nitschinger March 13, 2020 at 3:35 PM

This works against the current master, I've added a regression test in http://review.couchbase.org/#/c/123716/

Alex Cavnar December 18, 2019 at 9:04 PM

Hi there, 

I haven't-- I reported https://couchbasecloud.atlassian.net/browse/NCBC-2216#icft=NCBC-2216 on beta2, which kept me from attempting to replicate. Sorry! 

Jeffry Morris December 17, 2019 at 5:11 AM

-

Thanks, for the bug report! I see this is beta1, have you tried to recreate in beta2?

-Jeff

Cannot Reproduce
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created December 17, 2019 at 1:36 AM
Updated April 24, 2020 at 8:23 PM
Resolved March 15, 2020 at 5:56 AM
Instabug