hyperledger/fabric · error
unexpected collection type
Error message
unexpected collection type
What it means
While iterating stored collection configs to trim private collection entries, each CollectionConfig payload is type-switched. Only *CollectionConfig_StaticCollectionConfig is supported; any other payload variant causes this error, since the transient store only understands static collections.
Source
Thrown at core/transientstore/store_helper.go:234
func trimPvtCollectionConfigs(configs map[string]*peer.CollectionConfigPackage,
filter ledger.PvtNsCollFilter,
) (map[string]*peer.CollectionConfigPackage, error) {
if filter == nil {
return configs, nil
}
result := make(map[string]*peer.CollectionConfigPackage)
for ns, pkg := range configs {
result[ns] = &peer.CollectionConfigPackage{}
for _, colConf := range pkg.GetConfig() {
switch cconf := colConf.Payload.(type) {
case *peer.CollectionConfig_StaticCollectionConfig:
if filter.Has(ns, cconf.StaticCollectionConfig.Name) {
result[ns].Config = append(result[ns].Config, colConf)
}
default:
return nil, errors.New("unexpected collection type")
}
}
}
return result, nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Regenerate/rebuild the transient store data (drop and recreate the store directory)
- Align Fabric versions/protobuf definitions between peers writing and reading the store
- Clear stale transient store files after a Fabric upgrade
Defensive patterns
Strategy: validation
Validate before calling
// before reading the store, confirm all collection configs are static
cconf := rawConf.GetCollectionConfig()
if _, ok := cconf.Payload.(*peer.CollectionConfig_StaticCollectionConfig); !ok {
return errors.New("unsupported collection config type")
} Type guard
func isStaticCollectionConfig(c *peer.CollectionConfig) bool {
_, ok := c.GetPayload().(*peer.CollectionConfig_StaticCollectionConfig)
return ok
} Try / catch
iter, err := store.GetTxPvtRWSetByTxid(txid, filter)
if err != nil {
if strings.Contains(err.Error(), "unexpected collection type") {
// data written by incompatible Fabric version: rebuild transient store
}
return err
} Prevention
- Keep all peers on the same Fabric version
- Rebuild transient store after upgrades
- Avoid custom collection config variants in patched builds
- Validate collection configs at write time
When it happens
Trigger: Reading entries from the transient store (via Next()/retrieval with a filter) when a stored collection config message contains a payload type other than StaticCollectionConfig.
Common situations: Protobuf version mismatch between writer and reader (a collection config variant written by a newer/different Fabric version); corrupted transient store data.
Related errors
- collection-name: %s -- cannot unmarshal identity bytes into
- collection-name: %s -- cannot unmarshal identity bytes into
- error unmarshalling
- error encoding output
- error unmarshalling original config
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/3f600884c029b56a.
Report an issue: GitHub.