{"record":{"id":"e5238bcfd9b3491d","repo":"weaviate/weaviate","slug":"source-and-target-node-are-the-same-w","errorCode":null,"errorMessage":"source and target node are the same: %w","messagePattern":"source and target node are the same: %w","errorType":"validation","errorClass":"ErrBadRequest","httpStatus":400,"severity":"error","filePath":"cluster/replication/validate.go","lineNumber":35,"sourceCode":"\n\t\"github.com/weaviate/weaviate/cluster/proto/api\"\n\t\"github.com/weaviate/weaviate/cluster/schema\"\n)\n\nvar (\n\tErrAlreadyExists = errors.New(\"already exists\")\n\tErrNodeNotFound  = errors.New(\"node not found\")\n\tErrClassNotFound = errors.New(\"class not found\")\n\tErrShardNotFound = errors.New(\"shard not found\")\n)\n\n// ValidateReplicationReplicateShard validates that c is valid given the current state of the schema read using schemaReader\nfunc ValidateReplicationReplicateShard(schemaReader schema.SchemaReader, c *api.ReplicationReplicateShardRequest) error {\n\tif c.Uuid == \"\" {\n\t\treturn fmt.Errorf(\"uuid is required: %w\", ErrBadRequest)\n\t}\n\tif c.SourceNode == c.TargetNode {\n\t\treturn fmt.Errorf(\"source and target node are the same: %w\", ErrBadRequest)\n\t}\n\n\tclassInfo := schemaReader.ClassInfo(c.SourceCollection)\n\t// ClassInfo doesn't return an error, so the only way to know if the class exist is to check if the Exists\n\t// boolean is not set to default value\n\tif !classInfo.Exists {\n\t\treturn fmt.Errorf(\"collection %s does not exists: %w\", c.SourceCollection, ErrClassNotFound)\n\t}\n\n\t// Ensure source shard replica exists and target replica doesn't already exist\n\tnodes, err := schemaReader.ShardReplicas(c.SourceCollection, c.SourceShard)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar foundSource bool\n\tvar foundTarget bool\n\tfor _, n := range nodes {\n\t\tif n == c.SourceNode {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/cluster/replication/validate.go#L17-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Choose a target node that does not already host the shard; inspect current placement with GET /v1/schema/{class}/shards or replication status endpoints.","Verify sourceNode and targetNode fields in the request payload before submitting; they must be distinct cluster node names.","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."],"exampleFix":"// before\n{\"sourceNode\": \"node-1\", \"targetNode\": \"node-1\", ...}\n// after\n{\"sourceNode\": \"node-1\", \"targetNode\": \"node-2\", ...}","handlingStrategy":"validation","validationCode":"if req.SourceNode == req.TargetNode {\n  return errors.New(\"source and target node must differ\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch current shard replica placement before building replication requests.","Make replication automation idempotent: skip when desired placement already exists.","Validate node names against cluster membership before submitting."],"tags":["replication","validation","bad-request","distributed"],"backgroundTag":"invalid-replication-request","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}