hyperledger/fabric · error
invalid chaincode ID
Error message
invalid chaincode ID
What it means
The chaincode name taken from the header extension (hdrExt.ChaincodeId.Name) is an empty string. VSCC treats an empty ID as a sanity-check failure, logs it, and invalidates the transaction with TxValidationCode_INVALID_OTHER_REASON.
Source
Thrown at core/committer/txvalidator/v14/vscc_validator.go:101
return peer.TxValidationCode_BAD_RWSET, errors.WithMessage(err, "txRWSet.FromProtoBytes failed")
}
// Verify the header extension and response payload contain the ChaincodeId
if hdrExt.ChaincodeId == nil {
return peer.TxValidationCode_INVALID_OTHER_REASON, errors.New("nil ChaincodeId in header extension")
}
if respPayload.ChaincodeId == nil {
return peer.TxValidationCode_INVALID_OTHER_REASON, errors.New("nil ChaincodeId in ChaincodeAction")
}
// 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 {View on GitHub (pinned to 2736b63f8f)
Solutions
- Fix the client configuration so the chaincode name is a non-empty value at invoke time.
- Add client-side validation that rejects invoke requests with empty chaincodeName before submitting.
- Resubmit the transaction with the correct chaincode name.
Example fix
// before
ccName := os.Getenv("CHAINCODE_NAME") // may be ""
// after
ccName := os.Getenv("CHAINCODE_NAME")
if ccName == "" { return errors.New("chaincode name required") } Defensive patterns
Strategy: validation
Validate before calling
if chaincodeName == "" {
return fmt.Errorf("chaincode name must be non-empty before invoking transaction on channel %s", channelID)
} Type guard
func validChaincodeName(name string) bool {
return strings.TrimSpace(name) != ""
} Try / catch
if ccID == "" {
logger.Warnf("tx rejected: invalid chaincode ID")
return peer.TxValidationCode_INVALID_OTHER_REASON, nil
} Prevention
- Fail fast in client config loading when chaincode name is empty.
- Use explicit config with required-field checks rather than raw env reads.
- Add integration tests that assert a name is present in every invoke request.
When it happens
Trigger: ChaincodeHeaderExtension was marshalled with a ChaincodeID whose Name field is empty (or absent), e.g. a client passed an empty chaincode name to the SDK's invoke/send-transaction call.
Common situations: Misconfigured client where the chaincode name is read from an unset environment variable or config key (empty string); typos producing a blank name; generic tooling invoking transactions without resolving the target chaincode.
Related errors
- invalid chaincode version
- error unmarshalling ChaincodeHeaderExtension
- nil ChaincodeId in header extension
- nil ChaincodeId in ChaincodeAction
- inconsistent ccid info (%s/%s)
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5c1dc7a901bc769f.
Report an issue: GitHub.