{"record":{"id":"e5aef74252b97453","repo":"hyperledger/fabric","slug":"endorsement-failure-during-query-response-v","errorCode":null,"errorMessage":"endorsement failure during query. response: %v","messagePattern":"endorsement failure during query\\. response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/chaincode/common.go","lineNumber":129,"sourceCode":"\t\tlogger.Debugf(\"ESCC invoke result: %v\", proposalResp)\n\t\tpRespPayload, err := protoutil.UnmarshalProposalResponsePayload(proposalResp.Payload)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessage(err, \"error while unmarshalling proposal response payload\")\n\t\t}\n\t\tca, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessage(err, \"error while unmarshalling chaincode action\")\n\t\t}\n\t\tif proposalResp.Endorsement == nil {\n\t\t\treturn errors.Errorf(\"endorsement failure during invoke. response: %v\", proposalResp.Response)\n\t\t}\n\t\tlogger.Infof(\"Chaincode invoke successful. result: %v\", ca.Response)\n\t} else {\n\t\tif proposalResp == nil {\n\t\t\treturn errors.New(\"error during query: received nil proposal response\")\n\t\t}\n\t\tif proposalResp.Endorsement == nil {\n\t\t\treturn errors.Errorf(\"endorsement failure during query. response: %v\", proposalResp.Response)\n\t\t}\n\n\t\tif chaincodeQueryRaw && chaincodeQueryHex {\n\t\t\treturn fmt.Errorf(\"options --raw (-r) and --hex (-x) are not compatible\")\n\t\t}\n\t\tif chaincodeQueryRaw {\n\t\t\tfmt.Println(proposalResp.Response.Payload)\n\t\t\treturn nil\n\t\t}\n\t\tif chaincodeQueryHex {\n\t\t\tfmt.Printf(\"%x\\n\", proposalResp.Response.Payload)\n\t\t\treturn nil\n\t\t}\n\t\tfmt.Println(string(proposalResp.Response.Payload))\n\t}\n\treturn nil\n}\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L111-L147","documentation":"Error in chaincodeInvokeOrQuery's query path: the peer's proposal response has a nil Endorsement, so the query failed — typically the chaincode returned an error or the proposal was rejected. The %v carries the peer's response status and message describing the failure.","triggerScenarios":"peer chaincode query where proposalResp.Endorsement == nil after the response was received — the endorser refused or failed to endorse the query result.","commonSituations":"Chaincode returning an error status during query (e.g. key not found, chaincode not deployed), stale chaincode on the peer, endorsement policy failures.","solutions":["Read the response message in the error for the chaincode-level cause","Confirm the chaincode is committed on the channel and running on the queried peer","Ensure the queried peer has the latest ledger state (in sync)","Fix chaincode arguments/logic that caused the non-200 response"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"peer lifecycle chaincode querycommitted -C mychannel | grep -F \"$CHAINCODE_NAME\"\npeer chaincode query -C mychannel -n \"$CHAINCODE_NAME\" -c '{\"Args\":[\"health\"]}'","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"endorsement failure during query\") {\n  // parse the embedded proposalResp.Response for the chaincode-level reason\n  log.Errorf(\"query rejected by chaincode: %v\", err)\n}","preventionTips":["Read the response message embedded in the error before changing configs","Ensure the chaincode version committed matches what clients expect","Check the queried peer's ledger is at chain height","Use a smoke-test query key after chaincode upgrades"],"tags":["chaincode","query","endorsement"],"backgroundTag":"endorsement-failed","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"}