{"record":{"id":"aaaa6635f20fc8e5","repo":"hyperledger/fabric","slug":"invalid-chaincode-name-s-names-can-only-consis","errorCode":null,"errorMessage":"invalid chaincode name '%s'. Names can only consist of alphanumerics, '_', and '-' and can only begin with alphanumerics","messagePattern":"invalid chaincode name '(.+?)'\\. Names can only consist of alphanumerics, '_', and '-' and can only begin with alphanumerics","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/scc.go","lineNumber":727,"sourceCode":"\tChaincodeNameRegExp    = regexp.MustCompile(\"^[a-zA-Z0-9]+([-_][a-zA-Z0-9]+)*$\")\n\tChaincodeVersionRegExp = regexp.MustCompile(\"^[A-Za-z0-9_.+-]+$\")\n\n\tcollectionNameRegExp = regexp.MustCompile(\"^[A-Za-z0-9-]+([A-Za-z0-9_-]+)*$\")\n\n\t// currently defined system chaincode names that shouldn't\n\t// be allowed as user-defined chaincode names\n\tsystemChaincodeNames = map[string]struct{}{\n\t\t\"cscc\": {},\n\t\t\"escc\": {},\n\t\t\"lscc\": {},\n\t\t\"qscc\": {},\n\t\t\"vscc\": {},\n\t}\n)\n\nfunc (i *Invocation) validateInput(name, version string, collections *pb.CollectionConfigPackage) error {\n\tif !ChaincodeNameRegExp.MatchString(name) {\n\t\treturn errors.Errorf(\"invalid chaincode name '%s'. Names can only consist of alphanumerics, '_', and '-' and can only begin with alphanumerics\", name)\n\t}\n\tif _, ok := systemChaincodeNames[name]; ok {\n\t\treturn errors.Errorf(\"chaincode name '%s' is the name of a system chaincode\", name)\n\t}\n\n\tif !ChaincodeVersionRegExp.MatchString(version) {\n\t\treturn errors.Errorf(\"invalid chaincode version '%s'. Versions can only consist of alphanumerics, '_', '-', '+', and '.'\", version)\n\t}\n\n\tcollConfigs, err := extractStaticCollectionConfigs(collections)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// we extract the channel config to check whether the supplied collection configuration\n\t// complies to the given msp configuration and performs semantic validation.\n\t// Channel config may change afterwards (i.e., after endorsement or commit of this transaction).\n\t// Fabric will deal with the situation where some collection configs are no longer meaningful.\n\t// Therefore, the use of channel config for verifying during endorsement is more","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/scc.go#L709-L745","documentation":"validateInput enforces ChaincodeNameRegExp on the chaincode name supplied to ApproveChaincodeDefinitionForMyOrg or CommitChaincodeDefinition. Names may only contain alphanumerics, underscore, and dash, and must start with a letter or digit. Anything else is rejected.","triggerScenarios":"Submitting a chaincode name with spaces, dots, special characters, or leading underscore/dash via approveformyorg or commit.","commonSituations":"Using image-like names (e.g. 'my.org/chaincode'), file paths, or names with '@' or uppercase-with-symbols from CI pipelines.","solutions":["Rename the chaincode to match ^[a-zA-Z0-9_-]+$ with a leading alphanumeric","Strip any repository prefixes/paths before packaging and installing the chaincode","Add name normalization in CI before invoking lifecycle commands"],"exampleFix":"// before\nname := \"my.org/asset-transfer\"\n// after\nname := \"asset-transfer\"","handlingStrategy":"validation","validationCode":"// Go\nvar chaincodeNameRe = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]*$`)\nfunc isValidChaincodeName(name string) bool { return chaincodeNameRe.MatchString(name) }","typeGuard":null,"tryCatchPattern":"if !isValidChaincodeName(name) { return fmt.Errorf(\"invalid chaincode name %q\", name) }\n// then invoke approve/commit","preventionTips":["Validate names in CI before packaging chaincode","Strip registry/path prefixes from chaincode names","Document naming rules for chaincode authors"],"tags":["hyperledger-fabric","validation","naming"],"backgroundTag":"invalid-chaincode-name","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"}