{"record":{"id":"9cf87d7ae5cb616c","repo":"hyperledger/fabric","slug":"s-command-can-only-be-executed-against-one-peer","errorCode":null,"errorMessage":"'%s' command can only be executed against one peer. received %d","messagePattern":"'(.+?)' command can only be executed against one peer\\. received (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/chaincode/common.go","lineNumber":340,"sourceCode":"\t\t\t\tif peerChannelConfig.EndorsingPeer {\n\t\t\t\t\tpeerConfig, ok := networkConfig.Peers[peer]\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\treturn errors.Errorf(\"peer '%s' is defined in the channel config but doesn't have associated peer config\", peer)\n\t\t\t\t\t}\n\t\t\t\t\tpeerAddresses = append(peerAddresses, peerConfig.URL)\n\t\t\t\t\ttlsRootCertFiles = append(tlsRootCertFiles, peerConfig.TLSCACerts.Path)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// currently only support multiple peer addresses for invoke\n\tmultiplePeersAllowed := map[string]bool{\n\t\t\"invoke\": true,\n\t}\n\t_, ok := multiplePeersAllowed[cmdName]\n\tif !ok && len(peerAddresses) > 1 {\n\t\treturn errors.Errorf(\"'%s' command can only be executed against one peer. received %d\", cmdName, len(peerAddresses))\n\t}\n\n\tif len(tlsRootCertFiles) > len(peerAddresses) {\n\t\tlogger.Warningf(\"received more TLS root cert files (%d) than peer addresses (%d)\", len(tlsRootCertFiles), len(peerAddresses))\n\t}\n\n\tif viper.GetBool(\"peer.tls.enabled\") {\n\t\tif len(tlsRootCertFiles) != len(peerAddresses) {\n\t\t\treturn errors.Errorf(\"number of peer addresses (%d) does not match the number of TLS root cert files (%d)\", len(peerAddresses), len(tlsRootCertFiles))\n\t\t}\n\t} else {\n\t\ttlsRootCertFiles = nil\n\t}\n\n\treturn nil\n}\n\n// ChaincodeCmdFactory holds the clients used by ChaincodeCmd","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L322-L358","documentation":"This error is returned by validatePeerConnectionParameters when more than one peer address was supplied for a CLI command that only supports a single peer. Only the 'invoke' command is allowed to target multiple peers (for multi-endorsement); all other commands (query, install, instantiate, etc.) must be executed against exactly one peer.","triggerScenarios":"Running e.g. 'peer chaincode query' with --peerAddresses given twice (or with peers resolved from channel config producing multiple addresses), where cmdName is not 'invoke'.","commonSituations":"Copy-pasting an invoke command's multiple --peerAddresses flags into a query or lifecycle command, scripting that appends all channel peers regardless of the subcommand being run.","solutions":["Keep only one --peerAddresses flag for non-invoke commands","Use the command with multiple peers only with 'invoke'","If multiple endorsements are needed, use invoke with the required endorsement policy","Fix scripts to pass a single peer for query/lifecycle subcommands"],"exampleFix":"// before\npeer chaincode query -C mychannel -n mycc -c '{\"Args\":[\"Query\"]}' --peerAddresses peer0.org1:7051 --peerAddresses peer0.org2:7051\n// after\npeer chaincode query -C mychannel -n mycc -c '{\"Args\":[\"Query\"]}' --peerAddresses peer0.org1:7051","handlingStrategy":"validation","validationCode":"NADDR=$(grep -o -- '--peerAddresses' <<<\"$CMD\" | wc -l); [[ \"$SUBCMD\" == \"invoke\" || $NADDR -le 1 ]] || { echo \"$SUBCMD supports at most one peer\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass multiple --peerAddresses flags to invoke","Build command flags conditionally per subcommand in scripts","Use invoke for multi-endorsement scenarios, query for single-peer reads","Lint CLI wrappers to reject repeated --peerAddresses on non-invoke subcommands"],"tags":["hyperledger-fabric","cli","peer-addresses","endorsement"],"backgroundTag":"too-many-peer-endpoints","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}