{"record":{"id":"1e3d61a0f8780e92","repo":"hyperledger/fabric","slug":"invalid-configuration-for-collection-criteria-v","errorCode":null,"errorMessage":"invalid configuration for collection criteria %#v","messagePattern":"invalid configuration for collection criteria %#v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/common/privdata/store.go","lineNumber":113,"sourceCode":"\t\t\treturn nil, errors.WithMessagef(err, \"could not retrieve query executor for collection criteria %#v\", cc)\n\t\t}\n\t\tdefer qe.Done()\n\t}\n\treturn c.ccInfoProvider.AllCollectionsConfigPkg(cc.Channel, cc.Namespace, qe)\n}\n\n// RetrieveCollectionConfigPackageFromState retrieves the collection config package from the given key from the given state\nfunc RetrieveCollectionConfigPackageFromState(cc CollectionCriteria, state State) (*peer.CollectionConfigPackage, error) {\n\tcb, err := state.GetState(\"lscc\", BuildCollectionKVSKey(cc.Namespace))\n\tif err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"error while retrieving collection for collection criteria %#v\", cc)\n\t}\n\tif cb == nil {\n\t\treturn nil, NoSuchCollectionError(cc)\n\t}\n\tconf, err := ParseCollectionConfig(cb)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"invalid configuration for collection criteria %#v\", cc)\n\t}\n\treturn conf, nil\n}\n\n// ParseCollectionConfig parses the collection configuration from the given serialized representation.\nfunc ParseCollectionConfig(colBytes []byte) (*peer.CollectionConfigPackage, error) {\n\tcollections := &peer.CollectionConfigPackage{}\n\terr := proto.Unmarshal(colBytes, collections)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\treturn collections, nil\n}\n\n// RetrieveCollectionConfig retrieves a collection's config\nfunc (c *SimpleCollectionStore) RetrieveCollectionConfig(cc CollectionCriteria) (*peer.StaticCollectionConfig, error) {\n\treturn c.retrieveCollectionConfig(cc, nil)","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/common/privdata/store.go#L95-L131","documentation":"RetrieveCollectionConfigPackageFromState reads the serialized collection config package from the ledger state and parses it via ParseCollectionConfig. This (wrapped) error is returned when that parsing fails — the bytes stored on the ledger do not constitute a valid CollectionConfigPackage, so the collection criteria cannot be resolved. The error wraps the underlying parse error with the failing CollectionCriteria for context.","triggerScenarios":"Reading collection config from a transaction's write set or state where the stored bytes are corrupt, were written by an incompatible Fabric version, or were never valid collection config — hit from validateRWSetAndCollection during validation of private data.","commonSituations":"Ledger state produced by a chaincode that stored raw bytes instead of a marshaled CollectionConfigPackage, chaincode upgrades changing the stored config format, ledger corruption after crash/restore from backup.","solutions":["Check the wrapped cause (errors.Cause) to see the actual parse failure and fix the producing chaincode so it stores a valid marshaled CollectionConfigPackage","Re-commit the chaincode definition/collection config so a correct package is written to state","If ledger corruption is suspected, restore from a known-good backup or resync from peers"],"exampleFix":"// before\nstate.PutState(key, someRawJSONBytes) // stored non-proto bytes\n\n// after\nccpBytes, err := proto.Marshal(collectionConfigPackage)\nif err != nil { return err }\nstate.PutState(key, ccpBytes)","handlingStrategy":"try-catch","validationCode":"// before reading, verify stored bytes parse\nif len(cb) == 0 {\n  return errors.New(\"no collection config bytes in state for key\")\n}\nif _, err := privdata.ParseCollectionConfig(cb); err != nil {\n  return fmt.Errorf(\"state holds invalid collection config: %w\", err)\n}","typeGuard":"func isParsableCollectionConfig(b []byte) bool {\n  _, err := privdata.ParseCollectionConfig(b)\n  return err == nil\n}","tryCatchPattern":"conf, err := RetrieveCollectionConfigPackageFromState(cc, state)\nif err != nil {\n  log.Printf(\"wrapped cause: %v\", errors.Cause(err))\n  return fmt.Errorf(\"collection config unreadable for %+v: %w\", cc, err)\n}","preventionTips":["Only write proto.Marshal(CollectionConfigPackage) bytes to the state key","Inspect the wrapped cause for the real parse failure","Restore ledgers from consistent backups to avoid corruption"],"tags":["privdata","ledger-state","collection-config","parsing"],"backgroundTag":"invalid-collection-config","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"}