hyperledger/fabric · error

endorsement failure during query. response: %v

Error message

endorsement failure during query. response: %v

What it means

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.

Source

Thrown at internal/peer/chaincode/common.go:129

		logger.Debugf("ESCC invoke result: %v", proposalResp)
		pRespPayload, err := protoutil.UnmarshalProposalResponsePayload(proposalResp.Payload)
		if err != nil {
			return errors.WithMessage(err, "error while unmarshalling proposal response payload")
		}
		ca, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)
		if err != nil {
			return errors.WithMessage(err, "error while unmarshalling chaincode action")
		}
		if proposalResp.Endorsement == nil {
			return errors.Errorf("endorsement failure during invoke. response: %v", proposalResp.Response)
		}
		logger.Infof("Chaincode invoke successful. result: %v", ca.Response)
	} else {
		if proposalResp == nil {
			return errors.New("error during query: received nil proposal response")
		}
		if proposalResp.Endorsement == nil {
			return errors.Errorf("endorsement failure during query. response: %v", proposalResp.Response)
		}

		if chaincodeQueryRaw && chaincodeQueryHex {
			return fmt.Errorf("options --raw (-r) and --hex (-x) are not compatible")
		}
		if chaincodeQueryRaw {
			fmt.Println(proposalResp.Response.Payload)
			return nil
		}
		if chaincodeQueryHex {
			fmt.Printf("%x\n", proposalResp.Response.Payload)
			return nil
		}
		fmt.Println(string(proposalResp.Response.Payload))
	}
	return nil
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Read the response message in the error for the chaincode-level cause
  2. Confirm the chaincode is committed on the channel and running on the queried peer
  3. Ensure the queried peer has the latest ledger state (in sync)
  4. Fix chaincode arguments/logic that caused the non-200 response
Defensive patterns

Strategy: try-catch

Validate before calling

peer lifecycle chaincode querycommitted -C mychannel | grep -F "$CHAINCODE_NAME"
peer chaincode query -C mychannel -n "$CHAINCODE_NAME" -c '{"Args":["health"]}'

Try / catch

if err != nil && strings.Contains(err.Error(), "endorsement failure during query") {
  // parse the embedded proposalResp.Response for the chaincode-level reason
  log.Errorf("query rejected by chaincode: %v", err)
}

Prevention

When it happens

Trigger: peer chaincode query where proposalResp.Endorsement == nil after the response was received — the endorser refused or failed to endorse the query result.

Common situations: Chaincode returning an error status during query (e.g. key not found, chaincode not deployed), stale chaincode on the peer, endorsement policy failures.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/e5aef74252b97453. Report an issue: GitHub.