hyperledger/fabric · error

ChaincodeHeaderExtension.ChaincodeId.Name is empty

Error message

ChaincodeHeaderExtension.ChaincodeId.Name is empty

What it means

After confirming ChaincodeId is non-nil, UnpackProposal also requires the chaincode name to be non-empty; a proposal targeting an unnamed chaincode cannot be executed, so it is rejected with this error.

Source

Thrown at core/endorser/msgvalidation.go:73

		return nil, err
	}

	shdr, err := protoutil.UnmarshalSignatureHeader(hdr.SignatureHeader)
	if err != nil {
		return nil, err
	}

	chaincodeHdrExt, err := protoutil.UnmarshalChaincodeHeaderExtension(chdr.Extension)
	if err != nil {
		return nil, err
	}

	if chaincodeHdrExt.ChaincodeId == nil {
		return nil, errors.Errorf("ChaincodeHeaderExtension.ChaincodeId is nil")
	}

	if chaincodeHdrExt.ChaincodeId.Name == "" {
		return nil, errors.Errorf("ChaincodeHeaderExtension.ChaincodeId.Name is empty")
	}

	cpp, err := protoutil.UnmarshalChaincodeProposalPayload(prop.Payload)
	if err != nil {
		return nil, err
	}

	cis, err := protoutil.UnmarshalChaincodeInvocationSpec(cpp.Input)
	if err != nil {
		return nil, err
	}

	if cis.ChaincodeSpec == nil {
		return nil, errors.Errorf("chaincode invocation spec did not contain chaincode spec")
	}

	if cis.ChaincodeSpec.Input == nil {
		return nil, errors.Errorf("chaincode input did not contain any input")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Set ChaincodeId.Name (and Version) in the ChaincodeHeaderExtension when constructing the proposal
  2. Fix SDK/client configuration so the chaincode name is provided
  3. Add client-side validation that the chaincode name is non-empty before submitting

Example fix

// before
ccID := &pb.ChaincodeID{} // Name empty
// after
ccID := &pb.ChaincodeID{Name: "mycc", Version: "1.0"}
Defensive patterns

Strategy: validation

Validate before calling

if ext.ChaincodeId == nil || ext.ChaincodeId.Name == "" {
    return errors.New("chaincode name must be non-empty")
}

Type guard

func hasChaincodeName(ext *pb.ChaincodeHeaderExtension) bool {
    return ext != nil && ext.ChaincodeId != nil && ext.ChaincodeId.Name != ""
}

Prevention

When it happens

Trigger: Submitting a proposal whose ChaincodeHeaderExtension.ChaincodeId.Name is the empty string — typically a default-constructed ChaincodeID in the header extension.

Common situations: Hand-built proposals in tests/scripts forgetting to set the chaincode name; SDK misconfiguration where the chaincode name is empty/unset; template code with placeholder names.

Related errors


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