hyperledger/fabric · error
invalid configuration for collection criteria %#v
Error message
invalid configuration for collection criteria %#v
What it means
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.
Source
Thrown at core/common/privdata/store.go:113
return nil, errors.WithMessagef(err, "could not retrieve query executor for collection criteria %#v", cc)
}
defer qe.Done()
}
return c.ccInfoProvider.AllCollectionsConfigPkg(cc.Channel, cc.Namespace, qe)
}
// RetrieveCollectionConfigPackageFromState retrieves the collection config package from the given key from the given state
func RetrieveCollectionConfigPackageFromState(cc CollectionCriteria, state State) (*peer.CollectionConfigPackage, error) {
cb, err := state.GetState("lscc", BuildCollectionKVSKey(cc.Namespace))
if err != nil {
return nil, errors.WithMessagef(err, "error while retrieving collection for collection criteria %#v", cc)
}
if cb == nil {
return nil, NoSuchCollectionError(cc)
}
conf, err := ParseCollectionConfig(cb)
if err != nil {
return nil, errors.Wrapf(err, "invalid configuration for collection criteria %#v", cc)
}
return conf, nil
}
// ParseCollectionConfig parses the collection configuration from the given serialized representation.
func ParseCollectionConfig(colBytes []byte) (*peer.CollectionConfigPackage, error) {
collections := &peer.CollectionConfigPackage{}
err := proto.Unmarshal(colBytes, collections)
if err != nil {
return nil, errors.WithStack(err)
}
return collections, nil
}
// RetrieveCollectionConfig retrieves a collection's config
func (c *SimpleCollectionStore) RetrieveCollectionConfig(cc CollectionCriteria) (*peer.StaticCollectionConfig, error) {
return c.retrieveCollectionConfig(cc, nil)View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before
state.PutState(key, someRawJSONBytes) // stored non-proto bytes
// after
ccpBytes, err := proto.Marshal(collectionConfigPackage)
if err != nil { return err }
state.PutState(key, ccpBytes) Defensive patterns
Strategy: try-catch
Validate before calling
// before reading, verify stored bytes parse
if len(cb) == 0 {
return errors.New("no collection config bytes in state for key")
}
if _, err := privdata.ParseCollectionConfig(cb); err != nil {
return fmt.Errorf("state holds invalid collection config: %w", err)
} Type guard
func isParsableCollectionConfig(b []byte) bool {
_, err := privdata.ParseCollectionConfig(b)
return err == nil
} Try / catch
conf, err := RetrieveCollectionConfigPackageFromState(cc, state)
if err != nil {
log.Printf("wrapped cause: %v", errors.Cause(err))
return fmt.Errorf("collection config unreadable for %+v: %w", cc, err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Nil config passed to collection setup
- Collection config policy is nil
- Collection config access policy is nil
- expected two space separated tokens, but got %d
- unknown rule type '%s', expected ALL, ANY, or MAJORITY
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/1e3d61a0f8780e92.
Report an issue: GitHub.