hyperledger/fabric · error

failed to marshal updated readiness result

Error message

failed to marshal updated readiness result

What it means

When JSON output is requested and the readiness result contains approval mismatches, the CLI enriches the result with descriptions, then re-marshals it with proto.Marshal before printing. This error means that re-marshaling the in-memory protobuf failed, which is rare and typically indicates corrupted in-memory state.

Source

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

			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")
		}
		proposalResponse.Response.Payload = updatedPayload

		return printResponseAsJSON(proposalResponse, &lb.CheckCommitReadinessResult{}, c.Writer)
	}
	return c.printResponse(proposalResponse)
}

// mismatchItemWithDescription returns the item with its corresponding description
func (c *CommitReadinessChecker) mismatchItemWithDescription(item string) string {
	descriptions := map[string]string{
		"ChaincodeParameters": "ChaincodeParameters (Check the Sequence, ChaincodeName)",
		"EndorsementInfo":     "EndorsementInfo (Check the Version, InitRequired, EndorsementPlugin)",
		"ValidationInfo":      "ValidationInfo (Check the ValidationParameter, ValidationPlugin)",
		"Collections":         "Collections (Check the Collections)",
	}

	if description, ok := descriptions[item]; ok {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Retry the command — this is usually transient or a bug
  2. Omit --output json (use plain-text output) to bypass the re-marshal path
  3. Run without inspection (omit --enable-inspection style flag) so mismatches aren't enriched
  4. Report a bug with the wrapped error if reproducible

Example fix

// before
peer lifecycle chaincode checkcommitreadiness --output json ...
// after
peer lifecycle chaincode checkcommitreadiness ...   # plain-text output skips enriched re-marshal
Defensive patterns

Strategy: fallback

Validate before calling

// prefer plain output if json path is problematic
if strings.ToLower(outputFormat) == "json" && inspectionEnabled { log.Println("json+inspection exercises re-marshal path") }

Type guard

if readinessResult == nil || readinessResult.Mismatches == nil { skipRemarshal = true }

Try / catch

if _, err := proto.Marshal(readinessResult); err != nil { return printResponseAsJSON(proposalResponse, &lb.CheckCommitReadinessResult{}, w) }

Prevention

When it happens

Trigger: proto.Marshal(readinessResult) returns an error after mismatchItemWithDescription enrichment ran on a CheckCommitReadinessResult with non-nil Mismatches and --output json set.

Common situations: Practically only seen with corrupted fields injected into the result (e.g. invalid mismatch data) or a bug; not from normal user configuration.

Related errors


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