hyperledger/fabric · error
empty collection-name is not allowed
Error message
empty collection-name is not allowed
What it means
validateCollectionName rejects a private data collection whose name is the empty string. Collection names identify the collection in state metadata and gossip, so an empty name is invalid before any regex check is applied.
Source
Thrown at core/handlers/validation/builtin/v13/lscc_validation_logic.go:206
// Collection object itself is stored as value so that we can
// check whether the block to live is changed -- FAB-7810
newCollectionsMap[newCollection.GetName()] = newCollection
}
if err := checkForMissingCollections(newCollectionsMap, oldCollectionConfigs); err != nil {
return err
}
if err := checkForModifiedCollectionsBTL(newCollectionsMap, oldCollectionConfigs); err != nil {
return err
}
return nil
}
func validateCollectionName(collectionName string) error {
if collectionName == "" {
return fmt.Errorf("empty collection-name is not allowed")
}
match := validCollectionNameRegex.FindString(collectionName)
if len(match) != len(collectionName) {
return fmt.Errorf("collection-name: %s not allowed. A valid collection name follows the pattern: %s",
collectionName, AllowedCharsCollectionName)
}
return nil
}
// validateRWSetAndCollection performs validation of the rwset
// of an LSCC deploy operation and then it validates any collection
// configuration
func (vscc *Validator) validateRWSetAndCollection(
lsccrwset *kvrwset.KVRWSet,
cdRWSet *ccprovider.ChaincodeData,
lsccArgs [][]byte,
lsccFunc string,
ac vc.Capabilities,View on GitHub (pinned to 2736b63f8f)
Solutions
- Set a non-empty collection name in every StaticCollectionConfig entry
- Validate the collections JSON before submission: each entry must have a name matching the allowed-characters pattern
- Use the fabric CLI's collections-config parser locally to catch empty names early
Example fix
// before
{"name": "", "policy": "OR('Org1MSP.peer')"}
// after
{"name": "collectionOne", "policy": "OR('Org1MSP.peer')"} Defensive patterns
Strategy: validation
Validate before calling
function validateCollectionName(name) {
if (!name || name.length === 0) {
throw new Error('empty collection-name is not allowed');
}
} Type guard
function hasCollectionName(c) {
return typeof c.name === 'string' && c.name.length > 0;
} Try / catch
try {
await contract.submitTransaction('DeployChaincode', ...args);
} catch (err) {
if (String(err).includes('empty collection-name')) {
// set a valid name on every collection entry
}
throw err;
} Prevention
- Require a name field in the collections-config schema and reject empty strings
- Avoid leaving protobuf Name fields unset when building configs in code
- Lint collections JSON before every deploy/upgrade
When it happens
Trigger: Submitting a collection config where a StaticCollectionConfig has Name == "", via lifecycle --collections-config or a programmatically built CollectionConfigPackage.
Common situations: Building collection configs programmatically and leaving the Name field unset; JSON with {"name": ""}; deserialization that drops an empty field.
Related errors
- collection-name: %s not allowed. A valid collection name fol
- collection-name: %s -- maximum peer count (%d) cannot be les
- collection-name: %s -- requiredPeerCount (%d) cannot be less
- signature policy is not an OR concatenation, NOutOf %d
- the following existing collections are missing in the new co
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/2be26d39c4e8b090.
Report an issue: GitHub.