{"record":{"id":"46c2ac58a5741677","repo":"hyperledger/fabric","slug":"lscc-s-state-for-s-is-invalid-policy-field-mus","errorCode":null,"errorMessage":"lscc's state for [%s] is invalid, policy field must be set","messagePattern":"lscc's state for \\[(.+?)\\] is invalid, policy field must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v14/vscc_validator.go","lineNumber":322,"sourceCode":"\t\t}\n\t}\n\n\tif bytes == nil {\n\t\treturn nil, errors.Errorf(\"lscc's state for [%s] not found.\", ccid)\n\t}\n\n\tcd := &ccprovider.ChaincodeData{}\n\terr = proto.Unmarshal(bytes, cd)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unmarshalling ChaincodeQueryResponse failed\")\n\t}\n\n\tif cd.Vscc == \"\" {\n\t\treturn nil, errors.Errorf(\"lscc's state for [%s] is invalid, vscc field must be set\", ccid)\n\t}\n\n\tif len(cd.Policy) == 0 {\n\t\treturn nil, errors.Errorf(\"lscc's state for [%s] is invalid, policy field must be set\", ccid)\n\t}\n\n\treturn cd, err\n}\n\n// GetInfoForValidate gets the ChaincodeInstance(with latest version) of tx, vscc and policy from lscc\nfunc (v *VsccValidatorImpl) GetInfoForValidate(chdr *common.ChannelHeader, ccID string) (*sysccprovider.ChaincodeInstance, *sysccprovider.ChaincodeInstance, []byte, error) {\n\tcc := &sysccprovider.ChaincodeInstance{\n\t\tChannelID:     chdr.ChannelId,\n\t\tChaincodeName: ccID,\n\t}\n\tvscc := &sysccprovider.ChaincodeInstance{\n\t\tChannelID:     chdr.ChannelId,\n\t\tChaincodeName: \"vscc\", // default vscc for system chaincodes\n\t}\n\tvar policy []byte\n\tvar err error\n\tif !IsSysCC(ccID) {","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v14/vscc_validator.go#L304-L340","documentation":"The lscc ChaincodeData record has no endorsement policy bytes (cd.Policy is empty). The endorsement policy is mandatory because VSCC uses it to decide whether the transaction's endorsements satisfy the required signature set. Records lacking it are rejected with this error.","triggerScenarios":"getCDataForCC validates cd.Vscc then checks len(cd.Policy) == 0 — the lscc record was written without an endorsement policy, e.g. deployment with an empty/unresolvable -P policy.","commonSituations":"Instantiation with a malformed or empty endorsement policy expression; corrupted lscc state; custom lifecycle tooling omitting the policy field; failed policy parsing at deploy time.","solutions":["Upgrade/re-instantiate the chaincode with a valid endorsement policy (e.g. -P \"AND('Org1MSP.member','Org2MSP.member')\")","Verify the policy expression syntax resolves against the channel's MSPs","Rebuild the state database if lscc records are corrupted","If using custom lifecycle tooling, ensure it populates the Policy field in ChaincodeData"],"exampleFix":"// before\npeer chaincode instantiate -C mychannel -n mycc -v 1.0 -c '{...}' -P \"\"\n// after\npeer chaincode instantiate -C mychannel -n mycc -v 1.0 -c '{...}' -P \"AND('Org1MSP.member')\"","handlingStrategy":"validation","validationCode":"const policy = parsePolicyString(args.endorsementPolicy);\nif (!policy || policy.trim() === '') throw new Error('endorsement policy required');","typeGuard":"function hasPolicy(cd) {\n  return cd && Array.isArray(cd.policy) && cd.policy.length > 0;\n}","tryCatchPattern":"try { await instantiate(cc, {policy}); } catch (e) {\n  if (String(e).includes('policy field must be set')) { /* upgrade with a valid -P policy */ }\n}","preventionTips":["Always pass a valid -P endorsement policy at instantiate/upgrade","Validate policy syntax against channel MSP names","Verify ChaincodeData.Policy after deployment"],"tags":["hyperledger-fabric","lscc","endorsement-policy","invalid-state"],"backgroundTag":"endorsement-policy-missing","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"}