grpc/grpc-go · error

OutlierDetectionLoadBalancingConfig.interval =

Error message

OutlierDetectionLoadBalancingConfig.interval = %s; must be >= 0

What it means

Per gRFC A50, OutlierDetectionLoadBalancingConfig.interval must be a non-negative duration. ParseConfig checks lbCfg.Interval < 0 and rejects it (balancer.go:130-131). xdsclient performs the same check upstream so in the xDS flow this should never fire; it triggers when JSON is parsed directly.

Solutions

  1. Set interval to a non-negative value (A50 default is 10s).
  2. Validate the duration before constructing or sending the config.

Example fix

// before
cfg := &outlierdetection.LBConfig{Interval: iserviceconfig.Duration(-1 * time.Second)}
// after
cfg := &outlierdetection.LBConfig{Interval: iserviceconfig.Duration(10 * time.Second)}
Defensive patterns

Strategy: validation

Validate before calling

func validateInterval(d iserviceconfig.Duration) error {
    if d < 0 { return fmt.Errorf("interval must be >= 0, got %s", d) }
    return nil
}

Prevention

When it happens

Trigger: lbCfg.Interval is negative after JSON unmarshaling (e.g. "interval": "-10s" in the raw config).

Common situations: Hand-crafted config with a negative duration; xdsclient validation bypass (rare in production); typo or sign error in duration value.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/b81551711d7d8964. Report an issue: GitHub.

Appendix: source

Thrown at internal/xds/balancer/outlierdetection/balancer.go:131

	}

	// Note: in the xds flow, these validations will never fail. The xdsclient
	// performs the same validations as here on the xds Outlier Detection
	// resource before parsing resource into JSON which this function gets
	// called with. A50 defines two separate places for these validations to
	// take place, the xdsclient and this ParseConfig method. "When parsing a
	// config from JSON, if any of these requirements is violated, that should
	// be treated as a parsing error." - A50
	switch {
	// "The google.protobuf.Duration fields interval, base_ejection_time, and
	// max_ejection_time must obey the restrictions in the
	// google.protobuf.Duration documentation and they must have non-negative
	// values." - A50
	// Approximately 290 years is the maximum time that time.Duration (int64)
	// can represent. The restrictions on the protobuf.Duration field are to be
	// within +-10000 years. Thus, just check for negative values.
	case lbCfg.Interval < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.interval = %s; must be >= 0", lbCfg.Interval)
	case lbCfg.BaseEjectionTime < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.base_ejection_time = %s; must be >= 0", lbCfg.BaseEjectionTime)
	case lbCfg.MaxEjectionTime < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.max_ejection_time = %s; must be >= 0", lbCfg.MaxEjectionTime)

	// "The fields max_ejection_percent,
	// success_rate_ejection.enforcement_percentage,
	// failure_percentage_ejection.threshold, and
	// failure_percentage.enforcement_percentage must have values less than or
	// equal to 100." - A50
	case lbCfg.MaxEjectionPercent > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.max_ejection_percent = %v; must be <= 100", lbCfg.MaxEjectionPercent)
	case lbCfg.SuccessRateEjection != nil && lbCfg.SuccessRateEjection.EnforcementPercentage > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.SuccessRateEjection.enforcement_percentage = %v; must be <= 100", lbCfg.SuccessRateEjection.EnforcementPercentage)
	case lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.Threshold > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.threshold = %v; must be <= 100", lbCfg.FailurePercentageEjection.Threshold)
	case lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.EnforcementPercentage > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.enforcement_percentage = %v; must be <= 100", lbCfg.FailurePercentageEjection.EnforcementPercentage)

View on GitHub (pinned to 0c51461d27)