kubernetes/kubernetes · error

invalid feature name %q: must be no more than %d characters

Error message

invalid feature name %q: must be no more than %d characters

What it means

Thrown by validateNodeDeclaredFeatureName while validating node.spec.declaredFeatures entries. Each feature name must be no longer than validation.DNS1123SubdomainMaxLength (253 characters). The library enforces this cap so feature names stay compatible with Kubernetes label/subdomain constraints downstream.

Source

Thrown at pkg/apis/core/validation/validation.go:7578

}

func ValidateNodeSpecificAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}

	if annotations[core.TaintsAnnotationKey] != "" {
		allErrs = append(allErrs, ValidateTaintsInNodeAnnotations(annotations, fldPath)...)
	}

	if annotations[core.PreferAvoidPodsAnnotationKey] != "" {
		allErrs = append(allErrs, ValidateAvoidPodsInNodeAnnotations(annotations, fldPath)...)
	}
	return allErrs
}

// validateNodeDeclaredFeatureName checks if a declared feature name is valid.
func validateNodeDeclaredFeatureName(featureName string) error {
	if len(featureName) > validation.DNS1123SubdomainMaxLength {
		return fmt.Errorf("invalid feature name %q: must be no more than %d characters", featureName, validation.DNS1123SubdomainMaxLength)
	}
	if !nodeDeclaredFeatureRegexp.MatchString(featureName) {
		return fmt.Errorf("invalid feature name %q: must start with an UpperCamelCase segment, with subsequent segments separated by '/' (e.g., MyFeature or MyFeature/mySubFeature), and contain only alphanumeric characters and slashes", featureName)
	}
	return nil
}

func validateNodeDeclaredFeatures(nodeFeatures []string, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	// We do not need to check feature gate again here as we do it in dropDisabledFields() (pkg/registry/core/node/strategy.go)
	featureCount := len(nodeFeatures)
	for i, feature := range nodeFeatures {
		if err := validateNodeDeclaredFeatureName(feature); err != nil {
			allErrs = append(allErrs, field.Invalid(fldPath.Index(i), feature, err.Error()))
		}
		if i+1 < featureCount {
			nextFeature := nodeFeatures[i+1]
			if feature == nextFeature {

View on GitHub (pinned to b882c60b40)

Solutions

  1. Shorten the offending feature name to 253 characters or fewer.
  2. Split one oversized feature into several shorter, hierarchical entries (using '/' separators within the format rules).
  3. Check the generator/template producing the declaredFeatures list and cap the identifier length at the source.
Defensive patterns

Strategy: validation

Validate before calling

const maxFeatureLen = 253 // validation.DNS1123SubdomainMaxLength
if len(featureName) > maxFeatureLen {
    // reject / truncate / split before setting spec.declaredFeatures
}

Prevention

When it happens

Trigger: Submitting or updating a Node object whose spec.declaredFeatures array contains a string longer than 253 characters.

Common situations: A device plugin or node-feature-discovery style component synthesizes extremely long feature identifiers; concatenated namespace strings; copy-paste of a full path into the feature list.

Related errors


AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07). Data as JSON: /api/errors/46f2c89b17e5e4b6. Report an issue: GitHub.