hyperledger/fabric · error

'%s' contains illegal characters

Error message

'%s' contains illegal characters

What it means

Returned by ValidateChannelID when part of the channel ID matches the allowed-character regex but the whole string does not — i.e. the ID contains characters outside [a-zA-Z0-9.-_] (the length checks have already passed at this point).

Source

Thrown at common/configtx/validator.go:95

// with the following exception: '.' is converted to '_' in the CouchDB naming
// This is to accommodate existing channel names with '.', especially in the
// behave tests which rely on the dot notation for their sluggification.
//
// note: this function is a copy of the same in core/tx/endorser/parser.go
func ValidateChannelID(channelID string) error {
	re, _ := regexp.Compile(ChannelAllowedChars)
	// Length
	if len(channelID) <= 0 {
		return errors.Errorf("channel ID illegal, cannot be empty")
	}
	if len(channelID) > MaxLength {
		return errors.Errorf("channel ID illegal, cannot be longer than %d", MaxLength)
	}

	// Illegal characters
	matched := re.FindString(channelID)
	if len(matched) != len(channelID) {
		return errors.Errorf("'%s' contains illegal characters", channelID)
	}

	return nil
}

// NewValidatorImpl constructs a new implementation of the Validator interface.
func NewValidatorImpl(channelID string, config *cb.Config, namespace string, pm policies.Manager) (*ValidatorImpl, error) {
	if config == nil {
		return nil, errors.Errorf("nil config parameter")
	}

	if config.ChannelGroup == nil {
		return nil, errors.Errorf("nil channel group")
	}

	if err := ValidateChannelID(channelID); err != nil {
		return nil, errors.Errorf("bad channel ID: %s", err)
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Rename the channel using only [a-z][A-Z][0-9]._- characters
  2. Check for accidental whitespace or special characters copied into the channel ID
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at common/configtx/validator.go:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/6410be69cbdd5e9e. Report an issue: GitHub.