From 33ffbe5d1c1acf161782f3b47929c06b985ca204 Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Wed, 9 Sep 2026 18:46:10 -0300 Subject: [PATCH] fix(cluster): name the sharding-state shard the way the server sends it ShardReplica carried no @SerializedName, so Gson looked for the field's own name, shardName. The server sends "shard" (entities/models/replication_shard_replicas.go), so the component was null on every server version and a sharding-state response could not identify its shards. The client installs its own field-naming strategy (JSON.java:74 -> PropertyFieldNamingStrategy -> PojoDescriptor.propertyName), which honours only the ORM @Property annotation and otherwise returns the field name -- so the expected key really was "shardName". "replicas" matched by coincidence, the field name and the wire name agreeing; it is annotated here too so the record no longer depends on that. The Java component keeps its name: @SerializedName bridges it without a breaking rename. No alternate spelling -- nothing was ever stored or sent as "shardName". Closes #621 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01HNeKV7TAYZGDyT9agqJwUf --- .../client6/v1/api/cluster/ShardReplica.java | 6 +++++- .../client6/v1/internal/json/JSONTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/cluster/ShardReplica.java b/src/main/java/io/weaviate/client6/v1/api/cluster/ShardReplica.java index 4cd6304e1..9ea79e7c4 100644 --- a/src/main/java/io/weaviate/client6/v1/api/cluster/ShardReplica.java +++ b/src/main/java/io/weaviate/client6/v1/api/cluster/ShardReplica.java @@ -2,5 +2,9 @@ import java.util.List; -public record ShardReplica(String shardName, List replicas) { +import com.google.gson.annotations.SerializedName; + +public record ShardReplica( + @SerializedName("shard") String shardName, + @SerializedName("replicas") List replicas) { } diff --git a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java index e7c0d6203..02ce6d4ba 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java @@ -15,6 +15,8 @@ import com.jparams.junit4.data.DataMethod; import io.weaviate.client6.v1.api.cluster.NodeVerbosity; +import io.weaviate.client6.v1.api.cluster.ShardReplica; +import io.weaviate.client6.v1.api.cluster.ShardingState; import io.weaviate.client6.v1.api.collections.CollectionConfig; import io.weaviate.client6.v1.api.collections.Encoding; import io.weaviate.client6.v1.api.collections.Generative; @@ -2269,6 +2271,22 @@ public static Object[][] testCases() { } """ }, + // ShardingState: the server names the shard "shard", not "shardName" + { + ShardingState.class, + new ShardingState("Things", List.of(new ShardReplica("s1", List.of("node1", "node2")))), + """ + { + "collection": "Things", + "shards": [ + { + "shard": "s1", + "replicas": ["node1", "node2"] + } + ] + } + """ + }, }; }