{"record":{"id":"eb9243b7f4ff4e70","repo":"hyperledger/fabric","slug":"config-id-s-contains-illegal-characters","errorCode":null,"errorMessage":"config ID '%s' contains illegal characters","messagePattern":"config ID '(.+?)' contains illegal characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/configtx/validator.go","lineNumber":64,"sourceCode":"//  2. Are shorter than 250 characters.\n//  3. Are not the strings \".\" or \"..\".\nfunc validateConfigID(configID string) error {\n\tre, _ := regexp.Compile(configAllowedChars)\n\t// Length\n\tif len(configID) <= 0 {\n\t\treturn errors.New(\"config ID illegal, cannot be empty\")\n\t}\n\tif len(configID) > MaxLength {\n\t\treturn errors.Errorf(\"config ID illegal, cannot be longer than %d\", MaxLength)\n\t}\n\t// Illegal name\n\tif _, ok := illegalNames[configID]; ok {\n\t\treturn errors.Errorf(\"name '%s' for config ID is not allowed\", configID)\n\t}\n\t// Illegal characters\n\tmatched := re.FindString(configID)\n\tif len(matched) != len(configID) {\n\t\treturn errors.Errorf(\"config ID '%s' contains illegal characters\", configID)\n\t}\n\n\treturn nil\n}\n\n// ValidateChannelID makes sure that proposed channel IDs comply with the\n// following restrictions:\n//  1. Contain only lower case ASCII alphanumerics, dots '.', and dashes '-'\n//  2. Are shorter than 250 characters.\n//  3. Start with a letter\n//\n// This is the intersection of the Kafka restrictions and CouchDB restrictions\n// 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 core/tx/endorser/parser.go\nfunc ValidateChannelID(channelID string) error {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/configtx/validator.go#L46-L82","documentation":"validateConfigID permits only characters matching configAllowedChars in identifiers. If the whole string does not match the allowed-character pattern (checked by comparing the regex match length to the string length), it is rejected. This keeps config IDs restricted to safe name characters.","triggerScenarios":"Including spaces, slashes, '@', unicode, or other special characters in a config group/value/policy key; pasting names with surrounding whitespace or URL-encoded characters into config.","commonSituations":"Organization or policy names containing spaces or symbols imported from external systems; shell scripts that leave untrimmed whitespace in names; JSON/YAML config with typo'd or decorated keys.","solutions":["Remove or replace illegal characters with allowed ones (letters, digits, dot, dash) in the config ID","Trim whitespace from all names before adding them to config","Add a regex pre-check in tooling that generates config keys","Normalize external names (e.g. MSP IDs) into the allowed character set at import time"],"exampleFix":"// before\nid := fmt.Sprintf(\"%s peer\", orgName) // contains a space\n// after\nid := strings.ReplaceAll(strings.TrimSpace(orgName), \" \", \"-\") + \"-peer\"","handlingStrategy":"validation","validationCode":"var allowed = regexp.MustCompile(`^[a-zA-Z0-9.-]+$`)\nif !allowed.MatchString(configID) {\n    return errors.Errorf(\"config ID %q contains illegal characters\", configID)\n}","typeGuard":"func hasOnlyAllowedChars(id string) bool {\n    return id != \"\" && strings.TrimLeft(id, \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-\") == \"\"\n}","tryCatchPattern":"if err := validateName(id); err != nil {\n    return fmt.Errorf(\"config ID rejected: %w\", err)\n}","preventionTips":["Trim whitespace from all names entering config","Normalize external names to the allowed charset at import","Reject spaces and special characters in naming conventions","Test generated configs against the allowed-chars regex in CI"],"tags":["go","fabric","config","validation","naming"],"backgroundTag":"invalid-config-value","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"}