hyperledger/fabric · error

failed to unmarshal readiness result

Error message

failed to unmarshal readiness result

What it means

After a successful readiness query, the CLI unmarshals the response payload into a CheckCommitReadinessResult protobuf. This error means the payload bytes returned by the peer could not be parsed as that protobuf message, wrapped with the underlying unmarshal error.

Source

Thrown at internal/peer/lifecycle/chaincode/checkcommitreadiness.go:194

	if proposalResponse == nil {
		return errors.New("received nil proposal response")
	}

	if proposalResponse.Response == nil {
		return errors.New("received proposal response with nil response")
	}

	if proposalResponse.Response.Status != int32(cb.Status_SUCCESS) {
		return errors.Errorf("query failed with status: %d - %s", proposalResponse.Response.Status, proposalResponse.Response.Message)
	}

	if strings.ToLower(c.Input.OutputFormat) == "json" {
		// Unmarshal the proposal response to add descriptions to mismatch items
		readinessResult := &lb.CheckCommitReadinessResult{}
		err := proto.Unmarshal(proposalResponse.Response.Payload, readinessResult)
		if err != nil {
			return errors.Wrap(err, "failed to unmarshal readiness result")
		}

		if c.Input.InspectionEnabled {
			for org, mismatches := range readinessResult.Mismatches {
				for i, item := range mismatches.Items {
					mismatches.Items[i] = c.mismatchItemWithDescription(item)
				}
				readinessResult.Mismatches[org] = mismatches
			}
		} else {
			// If InspectionEnabled flag is OFF, clear the Mismatches
			readinessResult.Mismatches = nil
		}

		// Marshal back to proposalResponse
		updatedPayload, err := proto.Marshal(readinessResult)
		if err != nil {
			return errors.Wrap(err, "failed to marshal updated readiness result")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Ensure peer and CLI binaries are the same Fabric major version (2.x)
  2. Retry against a different peer to rule out a single bad peer
  3. Inspect the wrapped err for protobuf parse details to identify the payload format mismatch
  4. Upgrade/downgrade fabric binaries so the lifecycle protobuf schema matches
Defensive patterns

Strategy: validation

Validate before calling

// ensure peer and CLI versions match before querying
out, _ := exec.Command("peer", "version").Output()
if !strings.Contains(string(out), "2.") { log.Fatal("CLI must be Fabric 2.x to match peers") }

Type guard

if len(proposalResponse.Response.Payload) == 0 { return errors.New("empty payload") }

Try / catch

if _, err := proto.Unmarshal(payload, &lb.CheckCommitReadinessResult{}); err != nil { log.Printf("payload not a CheckCommitReadinessResult: %v", err) }

Prevention

When it happens

Trigger: proto.Unmarshal(proposalResponse.Response.Payload, readinessResult) fails — the peer returned a payload that is not a valid CheckCommitReadinessResult (mismatched peer/CLI versions, corrupted or unexpected payload).

Common situations: Mixed Fabric v1.x/v2.x network where the peer responds with a different payload format; custom/incompatible peer build; proxy or middleware mangling response 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/f17110a3f3a8b51b. Report an issue: GitHub.