Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2726

Cannot read empty response bodies

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.1.1
    • 3.1.0
    • library
    • None
    • 1

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              btburnett3 Brant Burnett
              btburnett3 Brant Burnett
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty