Unable to get subdoc update response

Java sdk 3.1.2
Couchbase 7.0
Below exception while reading subdoc update response
com.couchbase.client.core.error.InvalidArgumentException: Index 0 is invalid
at com.couchbase.client.core.error.InvalidArgumentException.fromMessage(InvalidArgumentException.java:28)
at com.couchbase.client.java.kv.MutateInResult.getFieldAtIndex(MutateInResult.java:118)
at com.couchbase.client.java.kv.MutateInResult.contentAs(MutateInResult.java:91)
at com.couchbase.client.java.kv.MutateInResult.contentAs(MutateInResult.java:68)

Reason is SubDocumentField encoded in MutateInResult is empty even after successful subdoc update . had cross verfied in db.

code used :
List mutateInSpecs contains 6 upsert command
MutateInResult mutationResult = reactiveCollection.mutateIn(docId, mutateInSpecs).block();
mutationResult.contentAs(0, String.class)

in addition to that , converting List to Flux is not starightforward
For e.g if have 30 fields to do subdoc update
splitting into 2 batches 16 operations ( max limit ) and 14 operation
would expecting response of each operation into String i.e Flux size 30 ;

Hi @selvarajc

Hmm, that’s curious… after a successful Sub-Document operation we should receive a SubDocumentField for each of the 6 specs back from the server. Could you share in more detail the exact MutateInSpecs you are performing please?

For your second question, I’m not sure I follow you completely, but if you have 30 Sub-Document specs to do on the same document, you might find it simpler and more efficient to do one regular full-document mutation instead, rather than two Sub-Document writes.

Could you share in more detail the exact MutateInSpecs you are performing please?

mutateInSpecs.add(upsert(propName, entry.getValue()));

For second question
doc has around 100 fileds out of which 30 fields are getting updated .
so subdoc is the right option

Hi @selvarajc
Without knowing what propName and entry.getValue() are, I’m unsure what’s going on. Is there any chance you can provide a small self-contained piece of code and data that reliably produces the problem?

upsert(“city”, “london”).createPath();
upsert(“country”, “UK”).createPath();
upsert(“manager.name”, “Hash”).createPath()
upsert(“managers.Food.name”, “Dhee”).createPath()

List mutateInSpecs = new LinkedList<>();

			mutateInSpecs.add(upsert(propName, entry.getValue()).createPath());
		if (updateCount == 16) {
			Mono<MutateInResult> mutationResult = reactiveCollection.mutateIn(docId, mutateInSpecs);
			updateCount = 0;
			mutateInSpecs = new LinkedList<>();

Flux subdocUpdates = Flux.fromIterable(subdocMutationsResults)
subdocUpdates.map(mr → { mr.contentAs(i, String.class)});