{"record":{"id":"c935b4022ec902bc","repo":"hyperledger/fabric","slug":"invalid-collection-configuration-supplied-for-chai","errorCode":null,"errorMessage":"invalid collection configuration supplied for chaincode %s:%s","messagePattern":"invalid collection configuration supplied for chaincode (.+?):(.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":438,"sourceCode":"\t\t\t\treturn &commonerrors.VSCCExecutionFailureError{\n\t\t\t\t\tErr: fmt.Errorf(\"unable to check whether collection existed earlier for chaincode %s:%s\",\n\t\t\t\t\t\tcdRWSet.Name, cdRWSet.Version),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ccp != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"collection data should not exist for chaincode %s:%s\", cdRWSet.Name, cdRWSet.Version))\n\t\t}\n\t}\n\n\t// TODO: Once the new chaincode lifecycle is available (FAB-8724), the following validation\n\t// and other validation performed in ValidateLSCCInvocation can be moved to LSCC itself.\n\tnewCollectionConfigPackage := &pb.CollectionConfigPackage{}\n\n\tif collectionsConfigArg != nil {\n\t\terr := proto.Unmarshal(collectionsConfigArg, newCollectionConfigPackage)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"invalid collection configuration supplied for chaincode %s:%s\",\n\t\t\t\tcdRWSet.Name, cdRWSet.Version))\n\t\t}\n\t} else {\n\t\treturn nil\n\t}\n\n\tif ac.V1_2Validation() {\n\t\tnewCollectionConfigs := newCollectionConfigPackage.GetConfig()\n\t\tif err := validateNewCollectionConfigs(newCollectionConfigs); err != nil {\n\t\t\treturn policyErr(err)\n\t\t}\n\n\t\tif lsccFunc == lscc.UPGRADE {\n\n\t\t\tcollectionCriteria := privdata.CollectionCriteria{Channel: channelName, Namespace: cdRWSet.Name}\n\t\t\t// oldCollectionConfigPackage denotes the existing collection config package in the ledger\n\t\t\toldCollectionConfigPackage, err := privdata.RetrieveCollectionConfigPackageFromState(collectionCriteria, state)\n\t\t\tif err != nil {","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L420-L456","documentation":"During transaction validation, VSCC's validateRWSetAndCollection unmarshals the collections-config argument supplied to an lscc DEPLOY/UPGRADE invocation into a pb.CollectionConfigPackage. This error means that protobuf unmarshal failed, i.e. the bytes in the collection configuration argument are not a valid serialized CollectionConfigPackage. It is thrown as a policy error, so the transaction is marked invalid.","triggerScenarios":"An lscc DEPLOY or UPGRADE transaction includes a collections-config argument (collectionsConfigArg != nil) whose bytes fail proto.Unmarshal into CollectionConfigPackage — e.g. corrupted, truncated, or non-protobuf bytes passed via the SDK's setCollectionsConfig, or a hand-built config marshaled incorrectly.","commonSituations":"Passing raw JSON/YAML collection config instead of the marshaled protobuf; SDK client bug or version mismatch producing malformed bytes; manually editing/constructing collection config bytes; copying a collection configuration between channels/tools incorrectly.","solutions":["Regenerate the collections-config argument by properly marshaling a pb.CollectionConfigPackage (use peer chaincode invoke flags or the SDK's CollectionConfig builder) instead of hand-crafting bytes.","Verify the collection config file passed to 'peer chaincode ... --collections-config' is valid JSON/YAML that the peer can convert; test with 'peer lifecycle' or a dry run.","Check SDK and fabric versions match (e.g. fabric-sdk-node/java vs peer version) so the message is serialized with compatible protobuf definitions.","Re-issue the transaction; since this is a policy error the tx is permanently invalid and must be re-submitted with a correct payload."],"exampleFix":"// before: passing a JSON file's raw bytes as collections config\nargs = append(args, rawConfigFileBytes)\n// after: build and marshal the protobuf properly\ncp := &pb.CollectionConfigPackage{Config: collectionConfigs}\nconfigBytes, err := proto.Marshal(cp)\nif err != nil { return err }\nargs = append(args, configBytes)","handlingStrategy":"validation","validationCode":"// client-side, before invoking lscc deploy/upgrade\ncp := &pb.CollectionConfigPackage{Config: configs}\nb, err := proto.Marshal(cp)\nif err != nil {\n    return fmt.Errorf(\"collection config failed to marshal: %w\", err)\n}\ncheck := &pb.CollectionConfigPackage{}\nif err := proto.Unmarshal(b, check); err != nil {\n    return fmt.Errorf(\"collection config roundtrip failed: %w\", err)\n}\nargs = append(args, b)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always roundtrip marshal/unmarshal the collection config before submitting.","Use CLI --collections-config or SDK CollectionConfig builders, never raw bytes.","Keep fabric peer and SDK protobuf versions in sync."],"tags":["hyperledger-fabric","vscc","protobuf","chaincode-lifecycle","collections-config"],"backgroundTag":"protobuf-unmarshal-failed","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"}