hyperledger/fabric · error

path element at %d is invalid

Error message

path element at %d is invalid

What it means

validateModPolicy splits the mod_policy on path separators and validates each element with validateConfigID. This error wraps the underlying validateConfigID failure, indicating some segment of the mod_policy path is empty or contains characters disallowed in config IDs.

Source

Thrown at common/configtx/update.go:62

		result[key] = value
	}
	return result
}

func validateModPolicy(modPolicy string) error {
	if modPolicy == "" {
		return errors.Errorf("mod_policy not set")
	}

	trimmed := modPolicy
	if modPolicy[0] == '/' {
		trimmed = modPolicy[1:]
	}

	for i, pathElement := range strings.Split(trimmed, pathSeparator) {
		err := validateConfigID(pathElement)
		if err != nil {
			return errors.Wrapf(err, "path element at %d is invalid", i)
		}
	}
	return nil
}

func (vi *ValidatorImpl) verifyDeltaSet(deltaSet map[string]comparable, signedData []*protoutil.SignedData) error {
	if len(deltaSet) == 0 {
		return errors.Errorf("delta set was empty -- update would have no effect")
	}

	for key, value := range deltaSet {
		logger.Debugf("Processing change to key: %s", key)
		if err := validateModPolicy(value.modPolicy()); err != nil {
			return errors.Wrapf(err, "invalid mod_policy for element %s", key)
		}

		existing, ok := vi.configMap[key]
		if !ok {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Fix the mod_policy string so each '/'-separated element is a valid config ID (non-empty, no illegal characters).
  2. Remove duplicated path separators or trailing slashes.
  3. Validate generated policy names before submitting the update.

Example fix

// before
ModPolicy: "/Channel/Application//Admins"
// after
ModPolicy: "/Channel/Application/Admins"
Defensive patterns

Strategy: validation

Validate before calling

func validModPolicyPath(p string) error {
  for i, el := range strings.Split(strings.TrimPrefix(p, "/"), "/") {
    if el == "" || strings.ContainsAny(el, " \t") {
      return fmt.Errorf("invalid path element %d in %q", i, p)
    }
  }
  return nil
}

Type guard

func isWellFormedModPolicy(p string) bool { return p != "" && !strings.Contains(p, "//") && strings.TrimSpace(p) == p }

Try / catch

if err := validateModPolicy(el.GetModPolicy()); err != nil {
  return fmt.Errorf("fix mod_policy path %q: %w", el.GetModPolicy(), err)
}

Prevention

When it happens

Trigger: A mod_policy like '/Channel//Admins' (empty element), or one containing invalid characters such as spaces or control characters, fails validateConfigID.

Common situations: Typos or double slashes in policy names in configtx.yaml or generated config; whitespace accidentally included in policy references.

Related errors


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