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

Mutating Null Causes 'KV Error: EINVAL'

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 3.0.5
    • None
    • None
    • None
    • 1
    • Medium

    Description

      Use case
      The document stored user profile information with an email field. The user clears his email and saves his profile.

      Steps to reproduce

      1. Create a new document

        {
            "name": "User1",
            "email": "email"
        }
        

      1. Mutate the document using the .NET client 3.0.5.

        class Program
        {
            private static ICluster _cluster;
         
            static async Task Main(string[] args)
            {
                var userInfo = new
                {
                    Name = "User1",
                    Email = (string)null
                };
         
                _cluster = await Cluster.ConnectAsync("couchbase://localhost", "Administrator", "Password");
         
                var bucket = await _cluster.BucketAsync("items");
                await bucket.DefaultCollection().MutateInAsync("doc1", new[]
                {
                    MutateInSpec.Upsert("name", userInfo.Name),
                    MutateInSpec.Upsert("email", userInfo.Email)
                });
         
                _cluster.Dispose();
            }
        }
        

      #The following exception is show:

      Couchbase.Core.Exceptions.InvalidArgumentException
      {"DispatchedFrom":null,"DispatchedTo":null,"DocumentKey":"doc1","ClientContextId":"19","Cas":0,"Status":4,"BucketName":"items","CollectionName":"_default","ScopeName":null,"Message":"KV Error: {Name=\"EINVAL\", Description=\"Invalid packet\", Attributes=\"internal,invalid-input\"}"}
      

      Attachments

        1. ConsoleApp1.zip
          2 kB
        2. console-example.log
          9 kB
        3. console-example.log
          9 kB
        4. console-example.log
          9 kB
        5. console-example.log
          9 kB
        6. console-example-internal.log
          1 kB
        7. console-example-internal.log
          1 kB
        8. console-example-internal.log
          1 kB
        9. console-example-internal.log
          1 kB

        Issue Links

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

          Activity

            narhangelov Nikolay Arhangelov added a comment - - edited

            The server version is Couchbase Enterprise 6.6.0 running in a Docker container.

            narhangelov Nikolay Arhangelov added a comment - - edited The server version is Couchbase Enterprise 6.6.0 running in a Docker container.
            narhangelov Nikolay Arhangelov added a comment - Related StackOverflow question -  Couchbase Server KV Error: “EINVAL” on null Upsert

            I can confirm this behavior. It's MutateInSpec.Upsert setting a null value which seems to be the problem. Here is the stack trace, and I've attached log output (just in case).

            Unhandled exception. Couchbase.Core.Exceptions.InvalidArgumentException: Exception of type 'Couchbase.Core.Exceptions.InvalidArgumentException' was thrown.
            {{ at Couchbase.Core.ClusterNode.ExecuteOp(Action`3 sender, IOperation op, Object state, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.Core.ClusterNode.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.Core.BucketBase.RetryAsync(IOperation operation, CancellationToken token, Nullable`1 timeout)}}
            {{ at Couchbase.KeyValue.CouchbaseCollection.MutateInAsync(String id, IEnumerable`1 specs, MutateInOptions options)}}
            {{ at ForumQuestions.Program.Main(String[] args) in c:\zproj\ForumQuestions\ForumQuestions\Program.cs:line 45}}
            {{ at ForumQuestions.Program.<Main>(String[] args)}}
            ----------------------Context Info--------------------------
            {{

            {"DispatchedFrom":null,"DispatchedTo":null,"DocumentKey":"doc1","ClientContextId":"19","Cas":0,"Status":4,"BucketName":"bucket","CollectionName":"_default","ScopeName":null,"Message":"KV Error: \{Name=\"EINVAL\", Description=\"Invalid packet\", Attributes=\"internal,invalid-input\"}

            "}}}

            console-example.log

            console-example-internal.log

            matthew.groves Matthew Groves added a comment - I can confirm this behavior. It's MutateInSpec.Upsert setting a null value which seems to be the problem. Here is the stack trace, and I've attached log output (just in case). Unhandled exception. Couchbase.Core.Exceptions.InvalidArgumentException: Exception of type 'Couchbase.Core.Exceptions.InvalidArgumentException' was thrown. {{ at Couchbase.Core.ClusterNode.ExecuteOp(Action`3 sender, IOperation op, Object state, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.Core.ClusterNode.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.Core.BucketBase.RetryAsync(IOperation operation, CancellationToken token, Nullable`1 timeout)}} {{ at Couchbase.KeyValue.CouchbaseCollection.MutateInAsync(String id, IEnumerable`1 specs, MutateInOptions options)}} {{ at ForumQuestions.Program.Main(String[] args) in c:\zproj\ForumQuestions\ForumQuestions\Program.cs:line 45}} {{ at ForumQuestions.Program.<Main>(String[] args)}} ---------------------- Context Info -------------------------- {{ {"DispatchedFrom":null,"DispatchedTo":null,"DocumentKey":"doc1","ClientContextId":"19","Cas":0,"Status":4,"BucketName":"bucket","CollectionName":"_default","ScopeName":null,"Message":"KV Error: \{Name=\"EINVAL\", Description=\"Invalid packet\", Attributes=\"internal,invalid-input\"} "}}} console-example.log console-example-internal.log

            People

              jmorris Jeff Morris
              narhangelov Nikolay Arhangelov
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty