hyperledger/fabric · error
collection-name: %s not allowed. A valid collection name fol
Error message
collection-name: %s not allowed. A valid collection name follows the pattern: %s
What it means
After the empty-name check, validateCollectionName applies validCollectionNameRegex to the collection name and requires the whole string to match. Names may only contain the characters described by AllowedCharsCollectionName (alphanumerics plus a limited set of symbols); any name containing disallowed characters is rejected with the pattern requirement spelled out.
Source
Thrown at core/handlers/validation/builtin/v13/lscc_validation_logic.go:210
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,
channelName string,
) commonerrors.TxValidationError {
/********************************************/
/* security check 0.a - validation of rwset */View on GitHub (pinned to 2736b63f8f)
Solutions
- Rename the collection using only allowed characters (typically alphanumeric plus '-', '_'); e.g. use 'coll1' not 'coll 1'
- Trim whitespace and validate the name against the documented pattern before submission
- Keep a shared naming convention (lowercase alphanumerics and hyphens) across teams and tooling
Example fix
// before
{"name": "my collection #1"}
// after
{"name": "my-collection-1"} Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = /^[a-zA-Z0-9_-]+$/; // mirror AllowedCharsCollectionName
function validateCollectionName(name) {
if (!ALLOWED.test(name)) {
throw new Error(`collection name '${name}' contains disallowed characters`);
}
} Type guard
function isValidCollectionName(name) {
return typeof name === 'string' && /^[a-zA-Z0-9_-]+$/.test(name);
} Try / catch
try {
await contract.submitTransaction('DeployChaincode', ...args);
} catch (err) {
if (String(err).includes('not allowed. A valid collection name')) {
// rename collections to match the allowed pattern
}
throw err;
} Prevention
- Restrict names to alphanumerics, hyphens, and underscores by convention
- Trim whitespace/newlines from names read from files or env vars
- Add a regex test to any tooling that generates collection configs
When it happens
Trigger: Submitting a collection config whose name contains characters outside the allowed set, e.g. spaces, slashes, unicode, 'coll#1' or 'my collection', during chaincode definition or upgrade.
Common situations: Using org/channel names or file paths (with slashes) as collection names; spaces instead of camelCase or hyphens; localized/unicode names; names copied with trailing whitespace or newline.
Related errors
- empty collection-name is not allowed
- 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/2ef4be7fc43ad918.
Report an issue: GitHub.