{"record":{"id":"8a34af186c73f0c3","repo":"hyperledger/fabric","slug":"invalid-chaincode-version-s-versions-can-only","errorCode":null,"errorMessage":"invalid chaincode version '%s'. Versions can only consist of alphanumerics, '_', '-', '+', and '.'","messagePattern":"invalid chaincode version '(.+?)'\\. Versions can only consist of alphanumerics, '_', '-', '\\+', and '\\.'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/scc.go","lineNumber":734,"sourceCode":"\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\n\t// towards catching manual errors in the config as oppose to any attempt of serializability.\n\tchannelConfig := i.SCC.ChannelConfigSource.GetStableChannelConfig(i.ChannelID)\n\tif channelConfig == nil {\n\t\treturn errors.Errorf(\"could not get channelconfig for channel '%s'\", i.ChannelID)\n\t}\n\tmspMgr := channelConfig.MSPManager()\n\tif mspMgr == nil {","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/scc.go#L716-L752","documentation":"Returned by lifecycle validateInput when the chaincode version fails ChaincodeVersionRegExp — it contains characters outside alphanumerics, '_', '-', '+', and '.'. The version string is part of the definition being approved/committed and is validated before any state is written.","triggerScenarios":"Approving/committing with versions containing spaces, slashes (e.g. 'v1.0/beta'), or other unsupported characters.","commonSituations":"Deriving versions from git tags or Docker tags that include '/', ':', or other characters, and passing them unmodified as the chaincode version.","solutions":["Sanitize the version string to match the allowed character set before invoking lifecycle commands","Map git/docker tags to a compliant version (e.g. 'v1.0-beta' instead of 'v1.0/beta')","Add a CI check validating the version before approve/commit"],"exampleFix":"// before\nversion := \"1.0.0/release\"\n// after\nversion := \"1.0.0-release\"","handlingStrategy":"validation","validationCode":"// Go\nvar chaincodeVersionRe = regexp.MustCompile(`^[a-zA-Z0-9_.+-]+$`)\nfunc isValidChaincodeVersion(v string) bool { return chaincodeVersionRe.MatchString(v) }","typeGuard":null,"tryCatchPattern":"if !isValidChaincodeVersion(version) { return fmt.Errorf(\"invalid chaincode version %q\", version) }\n// then invoke approve/commit","preventionTips":["Sanitize CI-generated versions derived from git/docker tags","Replace '/' and ':' in tags with '-' before use as version","Add a lint step validating version format"],"tags":["hyperledger-fabric","validation","versioning"],"backgroundTag":"invalid-chaincode-version","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"}