hyperledger/fabric · error · VSCCEndorsementPolicyError
invalid collection configuration supplied for chaincode %s:%
Error message
invalid collection configuration supplied for chaincode %s:%s
What it means
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.
Source
Thrown at core/handlers/validation/builtin/v12/validation_logic.go:438
return &commonerrors.VSCCExecutionFailureError{
Err: fmt.Errorf("unable to check whether collection existed earlier for chaincode %s:%s",
cdRWSet.Name, cdRWSet.Version),
}
}
}
if ccp != nil {
return policyErr(fmt.Errorf("collection data should not exist for chaincode %s:%s", cdRWSet.Name, cdRWSet.Version))
}
}
// TODO: Once the new chaincode lifecycle is available (FAB-8724), the following validation
// and other validation performed in ValidateLSCCInvocation can be moved to LSCC itself.
newCollectionConfigPackage := &pb.CollectionConfigPackage{}
if collectionsConfigArg != nil {
err := proto.Unmarshal(collectionsConfigArg, newCollectionConfigPackage)
if err != nil {
return policyErr(fmt.Errorf("invalid collection configuration supplied for chaincode %s:%s",
cdRWSet.Name, cdRWSet.Version))
}
} else {
return nil
}
if ac.V1_2Validation() {
newCollectionConfigs := newCollectionConfigPackage.GetConfig()
if err := validateNewCollectionConfigs(newCollectionConfigs); err != nil {
return policyErr(err)
}
if lsccFunc == lscc.UPGRADE {
collectionCriteria := privdata.CollectionCriteria{Channel: channelName, Namespace: cdRWSet.Name}
// oldCollectionConfigPackage denotes the existing collection config package in the ledger
oldCollectionConfigPackage, err := privdata.RetrieveCollectionConfigPackageFromState(collectionCriteria, state)
if err != nil {View on GitHub (pinned to 2736b63f8f)
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.
Example fix
// before: passing a JSON file's raw bytes as collections config
args = append(args, rawConfigFileBytes)
// after: build and marshal the protobuf properly
cp := &pb.CollectionConfigPackage{Config: collectionConfigs}
configBytes, err := proto.Marshal(cp)
if err != nil { return err }
args = append(args, configBytes) Defensive patterns
Strategy: validation
Validate before calling
// client-side, before invoking lscc deploy/upgrade
cp := &pb.CollectionConfigPackage{Config: configs}
b, err := proto.Marshal(cp)
if err != nil {
return fmt.Errorf("collection config failed to marshal: %w", err)
}
check := &pb.CollectionConfigPackage{}
if err := proto.Unmarshal(b, check); err != nil {
return fmt.Errorf("collection config roundtrip failed: %w", err)
}
args = append(args, b) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.
Related errors
- malformed chaincode invocation spec
- Upgrading non-existent chaincode %s
- Existing version of the cc on the ledger (%s) should be diff
- Unmarshal endorser error: %s
- unmarshalling of ChaincodeData failed, error %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/c935b4022ec902bc.
Report an issue: GitHub.