hyperledger/fabric · error

nil chaincode deployment spec

Error message

nil chaincode deployment spec

What it means

createSignedCCDepSpec was called with an empty/nil ChaincodeDeploymentSpec byte slice. The package envelope cannot be constructed without the serialized deployment spec that carries the chaincode definition.

Source

Thrown at core/common/ccpackage/ccpackage.go:82

	if bN != oN {
		return fmt.Errorf("Rule-all packages should be endorsed or none should be endorsed failed for (%d, %d)", bN, oN)
	}

	if !bytes.Equal(baseCip.ChaincodeDeploymentSpec, otherCip.ChaincodeDeploymentSpec) {
		return fmt.Errorf("Rule-all deployment specs should match(%d, %d)", len(baseCip.ChaincodeDeploymentSpec), len(otherCip.ChaincodeDeploymentSpec))
	}

	if !bytes.Equal(baseCip.InstantiationPolicy, otherCip.InstantiationPolicy) {
		return fmt.Errorf("Rule-all instantiation policies should match(%d, %d)", len(baseCip.InstantiationPolicy), len(otherCip.InstantiationPolicy))
	}

	return nil
}

func createSignedCCDepSpec(cdsbytes []byte, instpolicybytes []byte, endorsements []*peer.Endorsement) (*common.Envelope, error) {
	if cdsbytes == nil {
		return nil, errors.New("nil chaincode deployment spec")
	}

	if instpolicybytes == nil {
		return nil, errors.New("nil instantiation policy")
	}

	// create SignedChaincodeDeploymentSpec...
	cip := &peer.SignedChaincodeDeploymentSpec{ChaincodeDeploymentSpec: cdsbytes, InstantiationPolicy: instpolicybytes, OwnerEndorsements: endorsements}

	// ...and marshal it
	cipbytes := protoutil.MarshalOrPanic(cip)

	// use defaults (this is definitely ok for install package)
	msgVersion := int32(0)
	epoch := uint64(0)
	chdr := protoutil.MakeChannelHeader(common.HeaderType_CHAINCODE_PACKAGE, msgVersion, "", epoch)

	// create the payload

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Marshal the ChaincodeDeploymentSpec with protoutil before calling createSignedCCDepSpec
  2. Check upstream callers (SignExistingPackage, InitFromBuffer) for nil spec handling
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/common/ccpackage/ccpackage.go:82 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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