hyperledger/fabric · error

error unmarshalling updated config

Error message

error unmarshalling updated config

What it means

Returned by computeUpdt in configtxlator when proto.Unmarshal fails to decode the updated config bytes into a common.Config. The updated input was read but is not valid protobuf or not a Config message, so no config update can be computed against it.

Source

Thrown at cmd/configtxlator/main.go:213

	if err != nil {
		return errors.Wrapf(err, "error reading original config")
	}

	origConf := &cb.Config{}
	err = proto.Unmarshal(origIn, origConf)
	if err != nil {
		return errors.Wrapf(err, "error unmarshalling original config")
	}

	updtIn, err := io.ReadAll(updated)
	if err != nil {
		return errors.Wrapf(err, "error reading updated config")
	}

	updtConf := &cb.Config{}
	err = proto.Unmarshal(updtIn, updtConf)
	if err != nil {
		return errors.Wrapf(err, "error unmarshalling updated config")
	}

	cu, err := update.Compute(origConf, updtConf)
	if err != nil {
		return errors.Wrapf(err, "error computing config update")
	}

	cu.ChannelId = channelID

	outBytes, err := proto.Marshal(cu)
	if err != nil {
		return errors.Wrapf(err, "error marshaling computed config update")
	}

	_, err = output.Write(outBytes)
	if err != nil {
		return errors.Wrapf(err, "error writing config update to output")
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Encode the edited JSON back to binary: configtxlator encode --type common.Config before compute-update
  2. Validate the file with protoc --decode_raw
  3. Ensure the updated input is a full common.Config, not a ConfigUpdate
  4. Recreate the file if truncated or hand-edited

Example fix

// before
configtxlator compute-update --original orig.pb --updated updated.json ...
// after
configtxlator encode --input updated.json --output updt.pb --type common.Config && configtxlator compute-update --original orig.pb --updated updt.pb ...
Defensive patterns

Strategy: validation

Validate before calling

head -c1 "$UPDATED" | grep -q '{' && echo "updated is JSON; run configtxlator encode first" && exit 1
protoc --decode_raw < "$UPDATED" > /dev/null || { echo "invalid proto"; exit 1; }

Try / catch

out, err := cmd.CombinedOutput()
if err != nil && strings.Contains(string(out), "error unmarshalling updated config") {
    return fmt.Errorf("encode edited JSON to binary before compute-update: %w", err)
}

Prevention

When it happens

Trigger: Updated file is still JSON (encode step skipped or failed), contains a ConfigUpdate instead of Config, or is corrupted/truncated after manual edits.

Common situations: Editing config.json, forgetting to re-encode with configtxlator encode before compute-update; version mismatches in fabric-protos; partial writes.

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/20875521519794e1. Report an issue: GitHub.