{"record":{"id":"cd860ea953a4d1e5","repo":"hyperledger/fabric","slug":"invalid-key-for-the-collection-of-chaincode-s-s-cd860e","errorCode":null,"errorMessage":"invalid key for the collection of chaincode %s:%s; expected '%s', received '%s'","messagePattern":"invalid key for the collection of chaincode (.+?):(.+?); expected '(.+?)', received '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v13/lscc_validation_logic.go","lineNumber":247,"sourceCode":"\t/********************************************/\n\t// there can only be one or two writes\n\tif len(lsccrwset.Writes) > 2 {\n\t\treturn policyErr(fmt.Errorf(\"LSCC can only issue one or two putState upon deploy\"))\n\t}\n\n\t/**********************************************************/\n\t/* security check 0.b - validation of the collection data */\n\t/**********************************************************/\n\tvar collectionsConfigArg []byte\n\tif len(lsccArgs) > 5 {\n\t\tcollectionsConfigArg = lsccArgs[5]\n\t}\n\n\tvar collectionsConfigLedger []byte\n\tif len(lsccrwset.Writes) == 2 {\n\t\tkey := privdata.BuildCollectionKVSKey(cdRWSet.Name)\n\t\tif lsccrwset.Writes[1].Key != key {\n\t\t\treturn policyErr(fmt.Errorf(\"invalid key for the collection of chaincode %s:%s; expected '%s', received '%s'\",\n\t\t\t\tcdRWSet.Name, cdRWSet.Version, key, lsccrwset.Writes[1].Key))\n\t\t}\n\n\t\tcollectionsConfigLedger = lsccrwset.Writes[1].Value\n\t}\n\n\tif !bytes.Equal(collectionsConfigArg, collectionsConfigLedger) {\n\t\treturn policyErr(fmt.Errorf(\"collection configuration arguments supplied for chaincode %s:%s do not match the configuration in the lscc writeset\",\n\t\t\tcdRWSet.Name, cdRWSet.Version))\n\t}\n\n\tchannelState, err := vscc.stateFetcher.FetchState()\n\tif err != nil {\n\t\treturn &commonerrors.VSCCExecutionFailureError{Err: fmt.Errorf(\"failed obtaining query executor: %v\", err)}\n\t}\n\tdefer channelState.Done()\n\n\tstate := &state{channelState}","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v13/lscc_validation_logic.go#L229-L265","documentation":"validateRWSetAndCollection found the second LSCC write's key is not the expected collections KVS key ('chaincodeName~collection'). When two writes exist, the second must be the collections entry for the deployed chaincode.","triggerScenarios":"Thrown at core/handlers/validation/builtin/v13/lscc_validation_logic.go:247 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the deploy writes collection config under the proper collections key","Reject transactions with unexpected second LSCC writes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}