hyperledger/fabric · error

invalid chaincode version

Error message

invalid chaincode version

What it means

The chaincode version taken from respPayload.ChaincodeId.Version is empty. VSCC requires a version on the action's chaincode ID as a sanity check; an empty version invalidates the transaction with TxValidationCode_INVALID_OTHER_REASON.

Source

Thrown at core/committer/txvalidator/v14/vscc_validator.go:112

	// get name and version of the cc we invoked
	ccID := hdrExt.ChaincodeId.Name
	ccVer := respPayload.ChaincodeId.Version

	// sanity check on ccID
	if ccID == "" {
		err = errors.New("invalid chaincode ID")
		logger.Errorf("%+v", err)
		return peer.TxValidationCode_INVALID_OTHER_REASON, err
	}
	if ccID != respPayload.ChaincodeId.Name {
		err = errors.Errorf("inconsistent ccid info (%s/%s)", ccID, respPayload.ChaincodeId.Name)
		logger.Errorf("%+v", err)
		return peer.TxValidationCode_INVALID_OTHER_REASON, err
	}
	// sanity check on ccver
	if ccVer == "" {
		err = errors.New("invalid chaincode version")
		logger.Errorf("%+v", err)
		return peer.TxValidationCode_INVALID_OTHER_REASON, err
	}

	var wrNamespace []string
	alwaysEnforceOriginalNamespace := v.cr.Capabilities().V1_2Validation()
	if alwaysEnforceOriginalNamespace {
		wrNamespace = append(wrNamespace, ccID)
		if respPayload.Events != nil {
			ccEvent := &peer.ChaincodeEvent{}
			if err = proto.Unmarshal(respPayload.Events, ccEvent); err != nil {
				return peer.TxValidationCode_INVALID_OTHER_REASON, errors.Wrapf(err, "invalid chaincode event")
			}
			if ccEvent.ChaincodeId != ccID {
				return peer.TxValidationCode_INVALID_OTHER_REASON, errors.Errorf("chaincode event chaincode id does not match chaincode action chaincode id")
			}
		}
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Instantiate/upgrade the chaincode with an explicit non-empty version (e.g. 1.0) on the channel.
  2. Upgrade the peer to a version whose validation populates the action chaincode ID fully.
  3. Regenerate the transaction using the standard SDK flow so version info from the endorsing peer is included.

Example fix

// before
peer chaincode instantiate -C mychannel -n mycc -v '' ...
// after
peer chaincode instantiate -C mychannel -n mycc -v 1.0 -c '{"Args":["init"]}'
Defensive patterns

Strategy: validation

Validate before calling

if action.ChaincodeId.Version == "" {
    return errors.New("chaincode version missing in ChaincodeAction; deploy/upgrade with an explicit version")
}

Type guard

func hasChaincodeVersion(id *peer.ChaincodeID) bool {
	return id != nil && id.Version != ""
}

Try / catch

if ccVer == "" {
    logger.Warnf("tx rejected: invalid chaincode version")
    return peer.TxValidationCode_INVALID_OTHER_REASON, nil
}

Prevention

When it happens

Trigger: The ChaincodeAction's ChaincodeID was serialized without a Version field — e.g. the chaincode was instantiated/deployed without a version, or a custom response builder omitted it.

Common situations: Instantiating chaincode with an empty --version flag in older fabric-peer images; SDKs that omit version in the action payload; dev-mode testing where versions were never set.

Related errors


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