Description
When getting a document with an empty body, which may happen with LegacyTranscoder with null or empty strings, the operation throws an exception:
Specified argument was out of the range of valid values. (Parameter ‘start’) stack: at Couchbase.Utils.SlicedMemoryOwner1..ctor(IMemoryOwner1 memoryOwner, Int32 start, Int32 length)
at Couchbase.Core.IO.Operations.OperationBase.ExtractBody()
at Couchbase.KeyValue.CouchbaseCollection.GetAsync(String id, GetOptions options)
https://forums.couchbase.com/t/legacytranscoder-changed-from-version-3-0-7-to-3-1-0/28642
Repro:
[Theory]
|
[InlineData(null)] |
[InlineData("")] |
public async Task GetEmptyDoc_LegacyTranscoder(string content) |
{
|
const string id = nameof(GetEmptyDoc_LegacyTranscoder); |
var collection = await _fixture.GetDefaultCollection().ConfigureAwait(false); |
var transcoder = new LegacyTranscoder(new DefaultSerializer()); |
|
try |
{
|
await collection.InsertAsync(id, content, insertOptions => insertOptions.Transcoder(transcoder)) |
.ConfigureAwait(false); |
|
var getResult = await collection.GetAsync(id, getOptions => getOptions.Transcoder(transcoder)) |
.ConfigureAwait(false); |
var value = getResult.ContentAs<string>(); |
|
Assert.Null(value);
|
}
|
finally |
{
|
await collection.RemoveAsync(id).ConfigureAwait(false); |
}
|
}
|
Attachments
Issue Links
- is caused by
-
NCBC-2681 Pass the body to GetResult rather than the whole operation
- Resolved