Exception while query view

When I get some data through view of the bucket, there are some exception and the program terminated.

Exception in thread “main” com.couchbase.client.java.error.TranscodingException: Could not decode View JSON: {“id”:"(forgiving is an important part of love)}
at com.couchbase.client.java.view.ViewQueryResponseMapper$ByteBufToJsonObject.call(ViewQueryResponseMapper.java:106)
at com.couchbase.client.java.view.ViewQueryResponseMapper$ByteBufToJsonObject.call(ViewQueryResponseMapper.java:95)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:208)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:170)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.couchbase.client.deps.com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in VALUE_STRING
at [Source: [B@2f0dd706; line: 1, column: 97]
at com.couchbase.client.deps.com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1581)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:533)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:470)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:466)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserBase.loadMoreGuaranteed(ParserBase.java:459)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2431)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2411)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getValueAsString(UTF8StreamJsonParser.java:301)
at com.couchbase.client.java.transcoder.JacksonTransformers$AbstractJsonValueDeserializer.decodeObject(JacksonTransformers.java:59)
at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:134)
at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:129)
at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3702)
at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2817)
at com.couchbase.client.java.transcoder.JsonTranscoder.byteBufToClass(JsonTranscoder.java:107)
at com.couchbase.client.java.transcoder.JsonTranscoder.byteBufToJsonObject(JsonTranscoder.java:118)
at com.couchbase.client.java.view.ViewQueryResponseMapper$ByteBufToJsonObject.call(ViewQueryResponseMapper.java:104)
… 13 more
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.deps.io.netty.buffer.PooledUnsafeDirectByteBuf.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:104)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)
… 11 more

mmh that is quite strange… notice how the second closing quote is missing in your JSON?
can you trace the request/response or reproduce it in curl?
does it remotely look like the JSON you’d expect from this view?

I found that this exception occurred if the key contain }
The version of client is Couchbase-Java-Client-2.2.0

In file com.couchbase.client.java.transcoder.JsonTranscoder.java line 99:
int length = input.readableBytes();
return a false value when it found }, and the use this wrong length to call JacksonTransformers.MAPPER.readValue(inputBytes, offset, length, clazz)

Thanks for the additional info, this is indeed a bug.
I’ve opened https://issues.couchbase.com/browse/JVMCBC-263 to track it, I’ll get to it tomorrow and that should be fixed in 2.2.2.

Hi @simonbasle & @jiuchang2004

Is this issue fixed ?

Unfortunately we are still facing this issue when the document contains open/closing curl braces {}.
We have a encrypted content in one of the fields of the document and which may contain curl braces {}.
When retrieving this document we are facing the below error.

Any help is appreciated, thank you!

More details can be found at - https://forums.couchbase.com/t/com-couchbase-client-deps-com-fasterxml-jackson-core-jsonparseexception-m-couchbase-client-java-error-transcodingexception/15462?u=johnychandra.ch

m.couchbase.client.java.error.TranscodingException: Error deserializing row value from bytes to JsonObject
at com.couchbase.client.java.query.DefaultAsyncN1qlQueryRow.value(DefaultAsyncN1qlQueryRow.java:61)
at com.couchbase.client.java.query.DefaultN1qlQueryRow.value(DefaultN1qlQueryRow.java:48)
at com.couchbase.client.java.query.DefaultN1qlQueryRow.toString(DefaultN1qlQueryRow.java:53)

Caused by: com.couchbase.client.deps.com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in VALUE_STRING
at [Source: [B@7688047a; line: 11, column: 1625]
at com.couchbase.client.deps.com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1586)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:521)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:458)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:454)
at com.couchbase.client.deps.com.fasterxml.jackson.core.base.ParserBase.loadMoreGuaranteed(ParserBase.java:507)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2453)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2433)
at com.couchbase.client.deps.com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getValueAsString(UTF8StreamJsonParser.java:334)
at com.couchbase.client.java.transcoder.JacksonTransformers$AbstractJsonValueDeserializer.decodeObject(JacksonTransformers.java:86)
at com.couchbase.client.java.transcoder.JacksonTransformers$AbstractJsonValueDeserializer.decodeObject(JacksonTransformers.java:74)
at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:165)
at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:160)
at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2890)
at com.couchbase.client.java.query.DefaultAsyncN1qlQueryRow.value(DefaultAsyncN1qlQueryRow.java:58)
... 51 more

It was fixed quite a long time ago.

Are you able to reproduce this consistently? If so, can you run a test with logging turned up to TRACE/FINEST and point us to the output? Also, verify the log doesn’t show any issues at the server side if you can.

Thanks for your reply @ingenthr.
With 2.5.4 version this seems to be working fine.

I will see different combinations and keep the forum posted on this.