hyperledger/fabric · error

failed to unmarshal proposal response's response payload

Error message

failed to unmarshal proposal response's response payload

What it means

printResponse unmarshals the response payload into lb.QueryChaincodeDefinitionResult when a specific --name was given. This error (wrapped proto.Unmarshal failure) means the payload bytes are not a valid QueryChaincodeDefinitionResult protobuf.

Source

Thrown at internal/peer/lifecycle/chaincode/querycommitted.go:160

	}
	return c.printResponse(proposalResponse)
}

func (c *CommittedQuerier) printResponseAsJSON(proposalResponse *pb.ProposalResponse) error {
	if c.Input.Name != "" {
		return printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionResult{}, c.Writer)
	}
	return printResponseAsJSON(proposalResponse, &lb.QueryChaincodeDefinitionsResult{}, c.Writer)
}

// printResponse prints the information included in the response
// from the server as human readable plain-text.
func (c *CommittedQuerier) printResponse(proposalResponse *pb.ProposalResponse) error {
	if c.Input.Name != "" {
		result := &lb.QueryChaincodeDefinitionResult{}
		err := proto.Unmarshal(proposalResponse.Response.Payload, result)
		if err != nil {
			return errors.Wrap(err, "failed to unmarshal proposal response's response payload")
		}
		fmt.Fprintf(c.Writer, "Committed chaincode definition for chaincode '%s' on channel '%s':\n", c.Input.Name, c.Input.ChannelID)
		c.printSingleChaincodeDefinition(result)
		c.printApprovals(result)

		return nil
	}

	result := &lb.QueryChaincodeDefinitionsResult{}
	err := proto.Unmarshal(proposalResponse.Response.Payload, result)
	if err != nil {
		return errors.Wrap(err, "failed to unmarshal proposal response's response payload")
	}
	fmt.Fprintf(c.Writer, "Committed chaincode definitions on channel '%s':\n", c.Input.ChannelID)
	for _, cd := range result.ChaincodeDefinitions {
		fmt.Fprintf(c.Writer, "Name: %s, ", cd.Name)
		c.printSingleChaincodeDefinition(cd)
		fmt.Fprintf(c.Writer, "\n")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Ensure peer and CLI are the same Fabric major.minor version (lifecycle requires v2.x)
  2. Retry the query to rule out transport corruption
  3. Query without --name to see if the definitions-list path works
  4. Inspect raw payload via --outputFormat json to see what the peer actually returned
Defensive patterns

Strategy: try-catch

Validate before calling

// check peer/CLI version compatibility before running lifecycle commands
// peer version  &&  match major.minor to the CLI binary

Try / catch

if err := q.Query(); err != nil {
    if strings.Contains(err.Error(), "failed to unmarshal") {
        return fmt.Errorf("peer returned unexpected payload; check fabric version match")
    }
    return err
}

Prevention

When it happens

Trigger: Query with --name where the endorser returned SUCCESS but the payload is corrupt, empty, or of an unexpected message type (e.g. peer returns a different lifecycle result due to version mismatch).

Common situations: Fabric peer and CLI binaries from incompatible major versions (v2 CLI vs v1.x peer), a proxy rewriting payloads, or a custom/patched peer returning unexpected payload bytes.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


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