hyperledger/fabric · error
empty chaincode name in chaincode id
Error message
empty chaincode name in chaincode id
What it means
Thrown by the endorser parser's validate() when the ChaincodeID is present but its Name field is an empty string. A chaincode name is the minimum required routing key for a transaction; the library rejects anonymous chaincode invocations. Note ChaincodeID with only a Path/Version but no Name also triggers this.
Source
Thrown at core/tx/endorser/parser.go:153
if err := ValidateChannelID(e.ChannelID); err != nil {
return err
}
if len(e.Nonce) == 0 {
return errors.New("empty nonce")
}
if len(e.Creator) == 0 {
return errors.New("empty creator")
}
if e.ChaincodeID == nil {
return errors.New("nil ChaincodeId")
}
if e.ChaincodeID.Name == "" {
return errors.New("empty chaincode name in chaincode id")
}
// TODO FAB-16170: check proposal hash
// TODO FAB-16170: verify that txid matches the one in the header
// TODO FAB-16170: check that header in the tx action and channel header match bitwise
return nil
}
// UnmarshalEndorserTxAndValidate receives a tx.Envelope containing
// a partially unmarshalled endorser transaction and returns an EndorserTx
// instance (or an error)
func UnmarshalEndorserTxAndValidate(txenv *tx.Envelope) (*EndorserTx, error) {
etx, err := unmarshalEndorserTx(txenv)
if err != nil {
return nil, errView on GitHub (pinned to 2736b63f8f)
Solutions
- Ensure ChaincodeID.Name is set to the deployed chaincode's name before building the proposal.
- Validate the chaincode name source (config key, flag) is non-empty at startup.
- Fail fast in client code: if ccName == "" { return fmt.Errorf("chaincode name required") }.
Example fix
// before
ccid := &pb.ChaincodeID{Version: "1.0"}
// after
ccid := &pb.ChaincodeID{Name: "mycc", Version: "1.0"} Defensive patterns
Strategy: validation
Validate before calling
if spec.ChaincodeId == nil || spec.ChaincodeId.Name == "" { return errors.New("chaincode name required") } Type guard
func hasChaincodeName(spec *pb.ChaincodeSpec) bool { return spec != nil && spec.ChaincodeId != nil && spec.ChaincodeId.Name != "" } Prevention
- Source chaincode names from checked config with a required-field check at startup.
- Fail fast on empty name variables rather than passing them downstream.
- Centralize chaincode name constants instead of ad-hoc strings.
When it happens
Trigger: Creating a ChaincodeSpec with ChaincodeId set to &pb.ChaincodeID{} or with only Version/Path populated, then submitting the proposal through validation.
Common situations: Dynamic chaincode name variables that resolved to empty string due to config/env lookup failures; typos in struct field initialization; test fixtures omitting Name.
Related errors
- nil ChaincodeId
- only applicable for private data
- unknown operation type
- error reading chaincode install package at %s
- error unmarshalling ChaincodeHeaderExtension
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/a91b6e712d58e54b.
Report an issue: GitHub.