hyperledger/fabric · error

collection configuration is empty

Error message

collection configuration is empty

What it means

extractStaticCollectionConfigs walks each CollectionConfig in the package payload; when a StaticCollectionConfig entry is present but nil, there is no actual collection definition to use, so it rejects the package with 'collection configuration is empty'.

Source

Thrown at core/chaincode/lifecycle/scc.go:785

		return nil
	}
	if err := validateCollConfigsAgainstCommittedDef(collConfigs, committedCCDef.ExplicitCollectionConfigPkg); err != nil {
		return err
	}
	return nil
}

func extractStaticCollectionConfigs(collConfigPkg *pb.CollectionConfigPackage) ([]*pb.StaticCollectionConfig, error) {
	if collConfigPkg == nil || len(collConfigPkg.Config) == 0 {
		return nil, nil
	}
	collConfigs := make([]*pb.StaticCollectionConfig, len(collConfigPkg.Config))
	for i, c := range collConfigPkg.Config {
		switch t := c.Payload.(type) {
		case *pb.CollectionConfig_StaticCollectionConfig:
			collConfig := t.StaticCollectionConfig
			if collConfig == nil {
				return nil, errors.Errorf("collection configuration is empty")
			}
			collConfigs[i] = collConfig
		default:
			// this should only occur if a developer has added a new
			// collection config type
			return nil, errors.Errorf("collection config contains unexpected payload type: %T", t)
		}
	}
	return collConfigs, nil
}

func validateCollectionConfigs(collConfigs []*pb.StaticCollectionConfig, mspMgr msp.MSPManager) error {
	if len(collConfigs) == 0 {
		return nil
	}
	collNamesMap := map[string]struct{}{}
	// Process each collection config from a set of collection configs
	for _, c := range collConfigs {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Remove nil/placeholder entries from the collection config package before approval
  2. Fully populate each StaticCollectionConfig (name, member_orgs_policy, required_peer_count, max_peer_count, block_to_live)
  3. Regenerate the collection-config JSON and re-run approve/commit with the corrected package

Example fix

// before
collectionsConfig := [{ "static_collection_config": null }]
// after
collectionsConfig := [{ "name": "coll1", "member_orgs_policy": ..., "required_peer_count": 1, "max_peer_count": 2, "block_to_live": 0 }]
Defensive patterns

Strategy: validation

Validate before calling

// Go: pre-validate collection package entries are fully populated
func validateCollections(pkg *pb.CollectionConfigPackage) error {
    for _, c := range pkg.GetConfig() {
        sc := c.GetStaticCollectionConfig()
        if sc == nil || sc.Name == "" || sc.MemberOrgsPolicy == nil {
            return fmt.Errorf("collection config entry incomplete")
        }
    }
    return nil
}

Type guard

func asStaticCollection(c *pb.CollectionConfig) (*pb.StaticCollectionConfig, bool) {
    sc := c.GetStaticCollectionConfig()
    return sc, sc != nil
}

Try / catch

if err != nil && strings.Contains(err.Error(), "collection configuration is empty") {
    // reject collection config payload before approve/commit
}

Prevention

When it happens

Trigger: Submitting a CollectionConfigPackage whose Config array contains a CollectionConfig_StaticCollectionConfig wrapper with a nil StaticCollectionConfig, via ApproveChaincodeDefinitionForMyOrg or CommitChaincodeDefinition with collections.

Common situations: Constructing collection config JSON/protobuf programmatically and leaving a placeholder entry, or a client SDK emitting empty collection objects in the package.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/6a202dd684427bd6. Report an issue: GitHub.