hyperledger/fabric · error
lscc upgrade/deploy should not include a code packages
Error message
lscc upgrade/deploy should not include a code packages
What it means
In the legacy lscc deploy/upgrade path, the endorser invokes ExecuteLegacyInit with the chaincode spec; the code package must have already been installed. A proposal carrying a non-empty CodePackage in the CDS is rejected because install is a separate step from instantiate/upgrade.
Source
Thrown at core/endorser/endorser.go:160
// all state under one TxSimulator
//
// NOTE that if there's an error all simulation, including the chaincode
// table changes in lscc will be thrown away
cds, err := protoutil.UnmarshalChaincodeDeploymentSpec(input.Args[2])
if err != nil {
e.Metrics.SimulationFailure.With(meterLabels...).Add(1)
return nil, nil, err
}
// this should not be a system chaincode
if e.Support.IsSysCC(cds.ChaincodeSpec.ChaincodeId.Name) {
e.Metrics.SimulationFailure.With(meterLabels...).Add(1)
return nil, nil, errors.Errorf("attempting to deploy a system chaincode %s/%s", cds.ChaincodeSpec.ChaincodeId.Name, txParams.ChannelID)
}
if len(cds.CodePackage) != 0 {
e.Metrics.SimulationFailure.With(meterLabels...).Add(1)
return nil, nil, errors.Errorf("lscc upgrade/deploy should not include a code packages")
}
_, _, err = e.Support.ExecuteLegacyInit(txParams, cds.ChaincodeSpec.ChaincodeId.Name, cds.ChaincodeSpec.ChaincodeId.Version, cds.ChaincodeSpec.Input)
if err != nil {
// increment the failure to indicate instantion/upgrade failures
meterLabels = []string{
"channel", txParams.ChannelID,
"chaincode", cds.ChaincodeSpec.ChaincodeId.Name,
}
e.Metrics.InitFailed.With(meterLabels...).Add(1)
return nil, nil, err
}
return res, ccevent, err
}
// SimulateProposal simulates the proposal by calling the chaincode
func (e *Endorser) simulateProposal(txParams *ccprovider.TransactionParams, chaincodeName string, chaincodeInput *pb.ChaincodeInput) (*pb.Response, []byte, *pb.ChaincodeEvent, *pb.ChaincodeInterest, error) {View on GitHub (pinned to 2736b63f8f)
Solutions
- Install the chaincode package first (lifecycle chaincode install) and send an instantiate/upgrade proposal without a code package
- Strip the CodePackage from the CDS before submitting the instantiate/upgrade proposal
- Upgrade client SDK/tooling to the correct lifecycle flow
Example fix
// before cds.CodePackage = codeBytes // included in instantiate // after cds.CodePackage = nil // install separately, then instantiate
Defensive patterns
Strategy: validation
Validate before calling
if len(cds.CodePackage) != 0 {
return errors.New("instantiate proposal must not carry a code package; install first")
} Prevention
- Always install the chaincode package as a separate step before instantiate/upgrade
- Strip CodePackage from CDS in instantiate transactions
- Use current SDK lifecycle APIs instead of hand-built deploy transactions
When it happens
Trigger: Submitting an instantiate/upgrade proposal (via callChaincode with lscc) whose ChaincodeDeploymentSpec.CodePackage is non-empty.
Common situations: Old clients or scripts that bundled the code package into the deploy transaction instead of calling chaincode install first; SDK misuse combining install and instantiate steps.
Related errors
- attempting to deploy a system chaincode %s/%s
- no collection config for chaincode %#v
- received bad response, status %d: %s
- First message needs to be a register
- TLS is active but chaincode %s didn't send certificate
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/9d5a80257af095be.
Report an issue: GitHub.