grpc/grpc-go · error

error parsing Outlier Detection config

Error message

error parsing Outlier Detection config %v: %v

What it means

Returned by updateOutlierDetection (line 357) when odParser.ParseConfig(odJSON) fails on the outlier detection JSON from the cluster resource. The %v values are: first the raw odJSON (json.RawMessage), second the parse error. If the cluster has no outlier detection config, odJSON defaults to '{}' (line 352) which should always parse successfully — so a failure indicates non-empty, invalid OD config.

Solutions

  1. Inspect the full error which includes the raw OD JSON (%v) to see which fields are present.
  2. Validate the outlier detection parameters in the management server config: intervals must be positive durations, thresholds in [0,100], multipliers >= 1.
  3. Check for version compatibility — update the client or server so both agree on the OD schema.
  4. If outlier detection is not needed, remove it from the cluster resource on the management server side.
Defensive patterns

Strategy: validation

Validate before calling

// Validate outlier detection config JSON before it reaches the balancer
// (useful if you generate or proxy xDS resources):
func validateODConfig(raw json.RawMessage) error {
    var cfg struct {
        Interval           *json.RawMessage `json:"interval"`
        Enforcing          *uint32          `json:"enforcing_success_rate"`
        SuccessRateMinimum *uint32          `json:"success_rate_minimum_hosts"`
    }
    if err := json.Unmarshal(raw, &cfg); err != nil {
        return fmt.Errorf("invalid OD JSON: %w", err)
    }
    if cfg.Enforcing != nil && *cfg.Enforcing > 100 {
        return fmt.Errorf("enforcing_success_rate must be <= 100")
    }
    return nil
}

Try / catch

// Unwrap the error to inspect the raw OD JSON that failed:
err := getChannelError(conn)
if strings.Contains(err.Error(), "error parsing Outlier Detection") {
    // the %v in the message includes the raw JSON — inspect it
    // validate field values against the gRFC spec
}

Prevention

When it happens

Trigger: The CDS cluster resource contains an outlier detection configuration (envoy.config.cluster.v3.OutlierDetection) whose JSON representation the outlier detection balancer's ParseConfig rejects. This fires for each priority in b.priorities (line 348 loop).

Common situations: The management server sends outlier detection fields with invalid values (e.g., interval of 0, negative success rate threshold, enforcement_success_rate_minimum_hosts exceeding limits). Version skew where the server sends newer OD fields the client doesn't recognize or rejects. A control plane bug generating malformed OD JSON.

Related errors


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

Appendix: source

Thrown at internal/xds/balancer/cdsbalancer/cdsbalancer.go:357

		return fmt.Errorf("%q LB policy is needed but not registered", outlierdetection.Name)
	}

	odParser, ok := odBuilder.(balancer.ConfigParser)
	if !ok {
		// Shouldn't happen, imported Outlier Detection builder has this method.
		return fmt.Errorf("%q LB policy does not implement a config parser", outlierdetection.Name)
	}

	for _, p := range b.priorities {
		// Update Outlier Detection Config.
		odJSON := p.clusterConfig.Cluster.OutlierDetection
		if odJSON == nil {
			odJSON = json.RawMessage(`{}`)
		}

		lbCfg, err := odParser.ParseConfig(odJSON)
		if err != nil {
			return fmt.Errorf("error parsing Outlier Detection config %v: %v", odJSON, err)
		}

		odCfg, ok := lbCfg.(*outlierdetection.LBConfig)
		if !ok {
			// Shouldn't happen, Parser built at build time with Outlier
			// Detection builder pulled from gRPC LB Registry.
			return fmt.Errorf("config parser for Outlier Detection returned config with unexpected type %T: %v", lbCfg, lbCfg)
		}
		p.outlierDetection = *odCfg
	}
	return nil
}

// ResolverError handles errors reported by the xdsResolver.
func (b *cdsBalancer) ResolverError(err error) {
	// Missing Listener or RouteConfiguration on the management server
	// results in a 'resource not found' error from the xDS resolver. In
	// these cases, we should report transient failure.

View on GitHub (pinned to 0c51461d27)