{"record":{"id":"3cb47628b77adbed","repo":"hyperledger/fabric","slug":"lscc-s-state-for-s-is-invalid-vscc-field-must","errorCode":null,"errorMessage":"lscc's state for [%s] is invalid, vscc field must be set","messagePattern":"lscc's state for \\[(.+?)\\] is invalid, vscc field must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v14/vscc_validator.go","lineNumber":318,"sourceCode":"\tbytes, err := qe.GetState(\"lscc\", ccid)\n\tif err != nil {\n\t\treturn nil, &commonerrors.VSCCInfoLookupFailureError{\n\t\t\tReason: fmt.Sprintf(\"Could not retrieve state for chaincode %s, error %s\", ccid, err),\n\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","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v14/vscc_validator.go#L300-L336","documentation":"lscc state for the chaincode unmarshaled successfully, but its ChaincodeData has an empty Vscc field. Every deployed chaincode record must name the validation system chaincode (normally 'vscc') used to validate its transactions; a missing vscc field makes the record invalid and validation fails with this error.","triggerScenarios":"getCDataForCC unmarshals ChaincodeData with cd.Vscc == \"\" — the lscc record was created or modified without setting the vscc field.","commonSituations":"Corrupted or hand-crafted lscc records; lifecycle code bugs writing incomplete ChaincodeData; partial writes during chaincode deployment failures; state tampering.","solutions":["Re-instantiate or upgrade the chaincode so lscc writes a complete ChaincodeData including the vscc field","Repair/rebuild the state database if records were corrupted","Verify the deployment path used to deploy the chaincode wrote full ChaincodeData","Audit any custom tooling that modifies lscc state directly"],"exampleFix":"// before: incomplete ChaincodeData\ncd := &ChaincodeData{Name: \"mycc\", Version: \"1.0\"}\n// after\ncd := &ChaincodeData{Name: \"mycc\", Version: \"1.0\", Vscc: \"vscc\", Policy: policyBytes}","handlingStrategy":"validation","validationCode":"// pre-deploy sanity: ensure lifecycle writes vscc\n// after instantiate, verify record:\nconst cd = await channel.queryByChaincode({chaincodeId:'lscc', fcn:'getchaincodes'});","typeGuard":"function hasVsccField(cd) {\n  return cd && typeof cd.vscc === 'string' && cd.vscc.length > 0;\n}","tryCatchPattern":"try { await validate(); } catch (e) {\n  if (String(e).includes('vscc field must be set')) { /* re-instantiate/upgrade chaincode to rewrite ChaincodeData */ }\n}","preventionTips":["Use the standard instantiate/upgrade path, not custom state writes","Audit custom lifecycle tooling for complete ChaincodeData","Verify lscc records after deployment"],"tags":["hyperledger-fabric","lscc","chaincode-data","invalid-state"],"backgroundTag":"chaincode-data-invalid","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"}