Subdoc API mutateIn does not handle unicode

Hi,

I am trying to mutate a document with path “Fútbol” but receiving following error:

com.couchbase.client.java.error.subdoc.MultiMutationException: Multiple mutation could not be applied. First problematic failure at 0 with status SUBDOC_PATH_INVALID
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$16.call(AsyncMutateInBuilder.java:848)
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$16.call(AsyncMutateInBuilder.java:832)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.observers.Subscribers$5.onNext(Subscribers.java:235)
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
at rx.Subscriber.setProducer(Subscriber.java:209)
at rx.Subscriber.setProducer(Subscriber.java:205)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.Subscriber.setProducer(Subscriber.java:205)
at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:106)
at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:354)
at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:72)
at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:372)
at org.springframework.cloud.sleuth.instrument.rxjava.SleuthRxJavaSchedulersHook$TraceAction.call(SleuthRxJavaSchedulersHook.java:128)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.couchbase.client.java.error.subdoc.PathInvalidException: Path Fútbol ends in an array index in root, expected dictionary
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$5.call(AsyncMutateInBuilder.java:659)
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$5.call(AsyncMutateInBuilder.java:652)
at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$16.call(AsyncMutateInBuilder.java:842)
… 21 more
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.subdoc.simple.SimpleSubdocResponse.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:109)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
… 19 more

Please help.

FYI

This is what I am trying > bucket.mutateIn(“root”).insert(“Fútbol”, “value”, true).execute();

Have tried using backticks and also escaping, but in vain.

Which version of the SDK and what approximately does the doc look like before doing the mutation. I don’t immediately see anything that’d cause that. Note that the response there is returned by the server, not the client. @daschl or @mnunberg, any thoughts?

This could be a server side issue, the client correctly encodes the “Fútbol” as UTF-8 but if you try to store “Futbol” it works fine. Here is what goes on the wire:

With the accent:

         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 80 c7 00 04 03 00 00 34 00 00 00 15 00 00 00 01 |.......4........|
|00000010| 00 00 00 00 00 00 00 00 00 07 01 72 6f 6f 74    |...........root |
+--------+-------------------------------------------------+----------------+
[cb-io-1-1] 2017-03-24 08:23:07 TRACE LoggingHandler:94 - [id: 0x8459ac46, L:/127.0.0.1:54527 - R:localhost/127.0.0.1:11210] WRITE: 14B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 46 c3 ba 74 62 6f 6c 22 76 61 6c 75 65 22       |F..tbol"value"  |
+--------+-------------------------------------------------+----------------+

without the accent

         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 80 c7 00 04 03 00 00 34 00 00 00 14 00 00 00 01 |.......4........|
|00000010| 00 00 00 00 00 00 00 00 00 06 01 72 6f 6f 74    |...........root |
+--------+-------------------------------------------------+----------------+
[cb-io-1-1] 2017-03-24 08:22:13 TRACE LoggingHandler:94 - [id: 0xa5c70a21, L:/127.0.0.1:54468 - R:localhost/127.0.0.1:11210] WRITE: 13B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 46 75 74 62 6f 6c 22 76 61 6c 75 65 22          |Futbol"value"   |
+--------+-------------------------------------------------+----------------+

so it adds the extra byte needed for utf-8 accent, but the server responds with a “Caused by: com.couchbase.client.java.error.subdoc.PathInvalidException: Path Fútbol ends in an array index in root, expected dictionary” which is not expected I guess.

@mnunberg any idea?

I’ve raised https://issues.couchbase.com/browse/MB-23524 to track this.

1 Like

hi,

Using JAVA SDK 2.2.8.
The document is empty before the mutation.