weaviate/weaviate · error · ErrBadRequest

source and target node are the same: %w

Error message

source and target node are the same: %w

What it means

ValidateReplicationReplicateShard rejects a ReplicationReplicateShardRequest whose SourceNode equals TargetNode. Replicating a shard onto the node that already holds it is a no-op and would corrupt the replication bookkeeping, so the request is treated as a bad request (wrapped ErrBadRequest). The check is the second guard in validation, after requiring a request UUID.

Source

Thrown at cluster/replication/validate.go:35

	"github.com/weaviate/weaviate/cluster/proto/api"
	"github.com/weaviate/weaviate/cluster/schema"
)

var (
	ErrAlreadyExists = errors.New("already exists")
	ErrNodeNotFound  = errors.New("node not found")
	ErrClassNotFound = errors.New("class not found")
	ErrShardNotFound = errors.New("shard not found")
)

// ValidateReplicationReplicateShard validates that c is valid given the current state of the schema read using schemaReader
func ValidateReplicationReplicateShard(schemaReader schema.SchemaReader, c *api.ReplicationReplicateShardRequest) error {
	if c.Uuid == "" {
		return fmt.Errorf("uuid is required: %w", ErrBadRequest)
	}
	if c.SourceNode == c.TargetNode {
		return fmt.Errorf("source and target node are the same: %w", ErrBadRequest)
	}

	classInfo := schemaReader.ClassInfo(c.SourceCollection)
	// ClassInfo doesn't return an error, so the only way to know if the class exist is to check if the Exists
	// boolean is not set to default value
	if !classInfo.Exists {
		return fmt.Errorf("collection %s does not exists: %w", c.SourceCollection, ErrClassNotFound)
	}

	// Ensure source shard replica exists and target replica doesn't already exist
	nodes, err := schemaReader.ShardReplicas(c.SourceCollection, c.SourceShard)
	if err != nil {
		return err
	}
	var foundSource bool
	var foundTarget bool
	for _, n := range nodes {
		if n == c.SourceNode {

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Choose a target node that does not already host the shard; inspect current placement with GET /v1/schema/{class}/shards or replication status endpoints.
  2. Verify sourceNode and targetNode fields in the request payload before submitting; they must be distinct cluster node names.
  3. If the intent was to move the shard, note that replication copies then you must cancel the original replica as a separate step — the request is still valid as long as source != target.

Example fix

// before
{"sourceNode": "node-1", "targetNode": "node-1", ...}
// after
{"sourceNode": "node-1", "targetNode": "node-2", ...}
Defensive patterns

Strategy: validation

Validate before calling

if req.SourceNode == req.TargetNode {
  return errors.New("source and target node must differ")
}

Prevention

When it happens

Trigger: Calling the replication API (POST /v1/replication/replicate or ReplicationReplicateReplica) with a ReplicationReplicateShardRequest where sourceNode == targetNode, e.g. copy-pasting node names or scripting replication without inspecting the current replica placement.

Common situations: Automation that replicates a shard 'to node X' without first checking shard_replicas status; retrying a past successful replication with identical parameters; typos or stale cluster metadata where the operator believes the target is a different node.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/e5238bcfd9b3491d. Report an issue: GitHub.