{"record":{"id":"9d5a80257af095be","repo":"hyperledger/fabric","slug":"lscc-upgrade-deploy-should-not-include-a-code-pack","errorCode":null,"errorMessage":"lscc upgrade/deploy should not include a code packages","messagePattern":"lscc upgrade/deploy should not include a code packages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/endorser/endorser.go","lineNumber":160,"sourceCode":"\t// all state under one TxSimulator\n\t//\n\t// NOTE that if there's an error all simulation, including the chaincode\n\t// table changes in lscc will be thrown away\n\tcds, err := protoutil.UnmarshalChaincodeDeploymentSpec(input.Args[2])\n\tif err != nil {\n\t\te.Metrics.SimulationFailure.With(meterLabels...).Add(1)\n\t\treturn nil, nil, err\n\t}\n\n\t// this should not be a system chaincode\n\tif e.Support.IsSysCC(cds.ChaincodeSpec.ChaincodeId.Name) {\n\t\te.Metrics.SimulationFailure.With(meterLabels...).Add(1)\n\t\treturn nil, nil, errors.Errorf(\"attempting to deploy a system chaincode %s/%s\", cds.ChaincodeSpec.ChaincodeId.Name, txParams.ChannelID)\n\t}\n\n\tif len(cds.CodePackage) != 0 {\n\t\te.Metrics.SimulationFailure.With(meterLabels...).Add(1)\n\t\treturn nil, nil, errors.Errorf(\"lscc upgrade/deploy should not include a code packages\")\n\t}\n\n\t_, _, err = e.Support.ExecuteLegacyInit(txParams, cds.ChaincodeSpec.ChaincodeId.Name, cds.ChaincodeSpec.ChaincodeId.Version, cds.ChaincodeSpec.Input)\n\tif err != nil {\n\t\t// increment the failure to indicate instantion/upgrade failures\n\t\tmeterLabels = []string{\n\t\t\t\"channel\", txParams.ChannelID,\n\t\t\t\"chaincode\", cds.ChaincodeSpec.ChaincodeId.Name,\n\t\t}\n\t\te.Metrics.InitFailed.With(meterLabels...).Add(1)\n\t\treturn nil, nil, err\n\t}\n\n\treturn res, ccevent, err\n}\n\n// SimulateProposal simulates the proposal by calling the chaincode\nfunc (e *Endorser) simulateProposal(txParams *ccprovider.TransactionParams, chaincodeName string, chaincodeInput *pb.ChaincodeInput) (*pb.Response, []byte, *pb.ChaincodeEvent, *pb.ChaincodeInterest, error) {","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/endorser/endorser.go#L142-L178","documentation":"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.","triggerScenarios":"Submitting an instantiate/upgrade proposal (via callChaincode with lscc) whose ChaincodeDeploymentSpec.CodePackage is non-empty.","commonSituations":"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.","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"],"exampleFix":"// before\ncds.CodePackage = codeBytes // included in instantiate\n// after\ncds.CodePackage = nil // install separately, then instantiate","handlingStrategy":"validation","validationCode":"if len(cds.CodePackage) != 0 {\n    return errors.New(\"instantiate proposal must not carry a code package; install first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["endorser","chaincode","deployment","code-package"],"backgroundTag":"chaincode-code-package-in-instantiate","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}