{"record":{"id":"ba1b159cdabbe048","repo":"hyperledger/fabric","slug":"expected-a-static-collection-but-got-v-instead","errorCode":null,"errorMessage":"expected a static collection but got %v instead","messagePattern":"expected a static collection but got (.+?) instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/endorsement/collection.go","lineNumber":26,"sourceCode":"\nimport (\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/peer\"\n\t\"github.com/hyperledger/fabric/common/policies\"\n\t\"github.com/hyperledger/fabric/gossip/api\"\n\t\"github.com/pkg/errors\"\n)\n\nfunc principalsFromCollectionConfig(ccp *peer.CollectionConfigPackage) (principalSetsByCollectionName, error) {\n\tprincipalSetsByCollections := make(principalSetsByCollectionName)\n\tif ccp == nil {\n\t\treturn principalSetsByCollections, nil\n\t}\n\tfor _, colConfig := range ccp.Config {\n\t\tstaticCol := colConfig.GetStaticCollectionConfig()\n\t\tif staticCol == nil {\n\t\t\t// Right now we only support static collections, so if we got something else\n\t\t\t// we should refuse to process further\n\t\t\treturn nil, errors.Errorf(\"expected a static collection but got %v instead\", colConfig)\n\t\t}\n\t\tif staticCol.MemberOrgsPolicy == nil {\n\t\t\treturn nil, errors.Errorf(\"MemberOrgsPolicy of %s is nil\", staticCol.Name)\n\t\t}\n\t\tpol := staticCol.MemberOrgsPolicy.GetSignaturePolicy()\n\t\tif pol == nil {\n\t\t\treturn nil, errors.Errorf(\"policy of %s is nil\", staticCol.Name)\n\t\t}\n\t\tvar principals policies.PrincipalSet\n\t\t// We now extract all principals from the policy\n\t\tfor _, principal := range pol.Identities {\n\t\t\tprincipals = append(principals, principal)\n\t\t}\n\t\tprincipalSetsByCollections[staticCol.Name] = principals\n\t}\n\treturn principalSetsByCollections, nil\n}\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/endorsement/collection.go#L8-L44","documentation":"Discovery only supports static collections when computing endorsement principals from a collection config. When iterating the collection config package, if a collection entry cannot be cast to a StaticCollectionConfig (e.g. it is a different collection type in the future), discovery refuses to process it rather than guessing principals, returning this error.","triggerScenarios":"A chaincode's collection config on the channel contains a non-static collection config entry passed through loadMetadataForChannel and principalsFromCollectionConfig during PeersForEndorsement processing.","commonSituations":"Future/preview collection types written by newer Fabric tooling read by older discovery code; hand-crafted or corrupted collection configs deployed via chaincode definition; chaincode upgraded with an exotic collection spec.","solutions":["Re-deploy the chaincode collection configuration using only static collections","Inspect the collection config (peer lifecycle chaincode getcollectionsconfig / inspect config package) and remove non-static entries","Align Fabric versions between the tooling that created the config and the peers running discovery"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, col := range collConfig.Config {\n    if col.GetStaticCollectionConfig() == nil {\n        return fmt.Errorf(\"non-static collection %v rejected before discovery\", col)\n    }\n}","typeGuard":"func isStaticCollection(col *pb.CollectionConfig) bool {\n    return col.GetStaticCollectionConfig() != nil\n}","tryCatchPattern":"principals, err := coll.PrincipalsFromCollectionConfig(ccp)\nif err != nil {\n    if strings.Contains(err.Error(), \"expected a static collection\") {\n        return nil, fmt.Errorf(\"collection config for %s has non-static entries; redeploy with static collections\", cc)\n    }\n    return nil, err\n}","preventionTips":["Only deploy static collections via peer lifecycle tooling","Validate collection config JSON against the Fabric schema before approval","Keep Fabric tooling and peer versions aligned"],"tags":["discovery","collections","endorsement"],"backgroundTag":"unsupported-collection-type","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"}