{"record":{"id":"72c38ba4d0f29895","repo":"hyperledger/fabric","slug":"s-contains-illegal-characters-72c38b","errorCode":null,"errorMessage":"'%s' contains illegal characters","messagePattern":"'(.+?)' contains illegal characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tx/endorser/parser.go","lineNumber":207,"sourceCode":"// with the following exception: '.' is converted to '_' in the CouchDB naming\n// This is to accommodate existing channel names with '.', especially in the\n// behave tests which rely on the dot notation for their sluggification.\n//\n// note: this function is a copy of the same in common/configtx/validator.go\nfunc ValidateChannelID(channelID string) error {\n\tre, _ := regexp.Compile(ChannelAllowedChars)\n\t// Length\n\tif len(channelID) <= 0 {\n\t\treturn errors.Errorf(\"channel ID illegal, cannot be empty\")\n\t}\n\tif len(channelID) > MaxLength {\n\t\treturn errors.Errorf(\"channel ID illegal, cannot be longer than %d\", MaxLength)\n\t}\n\n\t// Illegal characters\n\tmatched := re.FindString(channelID)\n\tif len(matched) != len(channelID) {\n\t\treturn errors.Errorf(\"'%s' contains illegal characters\", channelID)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":189,"sourceCodeEnd":212,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/tx/endorser/parser.go#L189-L212","documentation":"ValidateChannelID checks the channel ID against ChannelAllowedChars via regexp; if the whole string is not a full match, it contains illegal characters. Allowed characters are lowercase alphanumerics plus '-' and '.' per Fabric's channel naming rules.","triggerScenarios":"Using uppercase letters, underscores, spaces, slashes, or unicode in a channel name — e.g. \"MyChannel\", \"my_channel\", \"org1/channel\".","commonSituations":"Deriving channel names from branch names containing '/', underscores, or uppercase (git branches like feature/XYZ); user-supplied names not sanitized; docker-compose env values with invalid chars.","solutions":["Normalize the name to lowercase and replace illegal characters with '-' before use.","Enforce the pattern ^[a-z][a-z0-9.-]*$ in your naming utility at creation time.","Use names of only lowercase letters, digits, '.', and '-' (and start with a letter per convention)."],"exampleFix":"// before\nname := strings.ToUpper(\"my_channel\")\n// after\nre := regexp.MustCompile(`[^a-z0-9.-]`)\nname := strings.ToLower(re.ReplaceAllString(\"my_channel\", \"-\"))","handlingStrategy":"validation","validationCode":"if !regexp.MustCompile(`^[a-z][a-z0-9.-]*$`).MatchString(channelID) { return fmt.Errorf(\"channel ID %q has illegal characters\", channelID) }","typeGuard":"var chRe = regexp.MustCompile(`^[a-z][a-z0-9.-]*$`)\nfunc channelIDCharsOK(id string) bool { return chRe.MatchString(id) }","tryCatchPattern":null,"preventionTips":["Sanitize user/branch-derived names to lowercase with '-' separators before use.","Reject illegal names at the CLI/config boundary with a clear message.","Reuse tx.ValidateChannelID in your tooling rather than duplicating rules."],"tags":["fabric","channel-id","validation"],"backgroundTag":"invalid-channel-id","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"}