Skip to content

fix(cluster): name the sharding-state shard the way the server sends it - #622

Open
dudanogueira wants to merge 2 commits into
mainfrom
fix/sharding-state-shard-name
Open

dudanogueira wants to merge 2 commits into
mainfrom
fix/sharding-state-shard-name

Conversation

@dudanogueira

@dudanogueira dudanogueira commented Sep 9, 2026 •

Copy link
Copy Markdown

The server sends the shard name in a sharding-state response as shard, but ShardReplica.shardName had no @SerializedName, so it was always null. This annotates the field and adds a JSONTest row for ShardingState.

Closes #621

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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HNeKV7TAYZGDyT9agqJwUf

@orca-security-eu orca-security-eu Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@bevzzz

bevzzz commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Please remove all comments from this PR and trim the PR description to what is strictly relevant.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the shard JSON mapping change.

No open issues 🎉

What changed in this PR

Fixes #621 by mapping the server’s shard JSON key to ShardReplica.shardName, preserving the existing Java API.

Changes:

  • Adds explicit JSON field names for shardName and replicas.
  • Adds a ShardingState JSON test case using the server’s response format.
File Description
src/​test/​java/​io/​weaviate/​client6/​v1/​internal/​json/​JSONTest.java Adds regression coverage for shard names and replicas.
src/​main/​java/​io/​weaviate/​client6/​v1/​api/​cluster/​ShardReplica.java Annotates record components with their JSON field names.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v6: ShardReplica.shardName has no @SerializedName, so the shard is always null

3 participants