{"record":{"id":"e371e395c9f0dac4","repo":"hyperledger/fabric","slug":"channel-id-illegal-cannot-be-longer-than-d","errorCode":null,"errorMessage":"channel ID illegal, cannot be longer than %d","messagePattern":"channel ID illegal, cannot be longer than (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/configtx/validator.go","lineNumber":89,"sourceCode":"// 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 {\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\n// NewValidatorImpl constructs a new implementation of the Validator interface.\nfunc NewValidatorImpl(channelID string, config *cb.Config, namespace string, pm policies.Manager) (*ValidatorImpl, error) {\n\tif config == nil {\n\t\treturn nil, errors.Errorf(\"nil config parameter\")\n\t}\n\n\tif config.ChannelGroup == nil {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/configtx/validator.go#L71-L107","documentation":"ValidateChannelID enforces a maximum channel ID length of MaxLength (250) characters. IDs longer than this are rejected with the limit included in the message, keeping channel names within protocol bounds.","triggerScenarios":"Creating a channel whose name exceeds 250 characters; generating channel IDs by concatenating long environment/tenant prefixes.","commonSituations":"Automation deriving channel names from long org + region + environment strings; copying long domain names as channel IDs; nested tenant hierarchies flattened into one long channel name.","solutions":["Shorten the channel name to at most 250 characters","Use a compact naming convention for channels and store long names in config metadata","Add a length guard in any script that composes channel names","Validate with ValidateChannelID or configtxgen before submitting the create-channel transaction"],"exampleFix":"// before\nchannel := orgName + \"-\" + region + \"-\" + env + \"-channel\" // >250 chars\n// after\nchannel := abbreviate(orgName) + \"-\" + region + \"-\" + env // <=250 chars\nif err := configtx.ValidateChannelID(channel); err != nil { ... }","handlingStrategy":"validation","validationCode":"const maxLen = 250\nif len(channelID) > maxLen {\n    return errors.Errorf(\"channel ID %d chars exceeds max %d\", len(channelID), maxLen)\n}","typeGuard":"func validChannelIDLength(id string) bool {\n    return len(id) <= 250\n}","tryCatchPattern":"if err := configtx.ValidateChannelID(chID); err != nil {\n    return fmt.Errorf(\"channel ID rejected: %w\", err)\n}","preventionTips":["Keep channel naming conventions short and compact","Add length checks in automation that composes channel names","Use configtxgen validation before submitting create-channel txs","Store long descriptive names in config metadata, not the channel ID"],"tags":["go","fabric","channel","validation","naming"],"backgroundTag":"channel-id-validation-failed","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"}