{"record":{"id":"3a9a0b3c164290b0","repo":"grpc/grpc-go","slug":"outlierdetectionloadbalancingconfig-max-ejection-t","errorCode":null,"errorMessage":"OutlierDetectionLoadBalancingConfig.max_ejection_time = %s; must be >= 0","messagePattern":"OutlierDetectionLoadBalancingConfig\\.max_ejection_time = (.+?); must be >= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/outlierdetection/balancer.go","lineNumber":135,"sourceCode":"\t// resource before parsing resource into JSON which this function gets\n\t// called with. A50 defines two separate places for these validations to\n\t// take place, the xdsclient and this ParseConfig method. \"When parsing a\n\t// config from JSON, if any of these requirements is violated, that should\n\t// be treated as a parsing error.\" - A50\n\tswitch {\n\t// \"The google.protobuf.Duration fields interval, base_ejection_time, and\n\t// max_ejection_time must obey the restrictions in the\n\t// google.protobuf.Duration documentation and they must have non-negative\n\t// values.\" - A50\n\t// Approximately 290 years is the maximum time that time.Duration (int64)\n\t// can represent. The restrictions on the protobuf.Duration field are to be\n\t// within +-10000 years. Thus, just check for negative values.\n\tcase lbCfg.Interval < 0:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.interval = %s; must be >= 0\", lbCfg.Interval)\n\tcase lbCfg.BaseEjectionTime < 0:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.base_ejection_time = %s; must be >= 0\", lbCfg.BaseEjectionTime)\n\tcase lbCfg.MaxEjectionTime < 0:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.max_ejection_time = %s; must be >= 0\", lbCfg.MaxEjectionTime)\n\n\t// \"The fields max_ejection_percent,\n\t// success_rate_ejection.enforcement_percentage,\n\t// failure_percentage_ejection.threshold, and\n\t// failure_percentage.enforcement_percentage must have values less than or\n\t// equal to 100.\" - A50\n\tcase lbCfg.MaxEjectionPercent > 100:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.max_ejection_percent = %v; must be <= 100\", lbCfg.MaxEjectionPercent)\n\tcase lbCfg.SuccessRateEjection != nil && lbCfg.SuccessRateEjection.EnforcementPercentage > 100:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.SuccessRateEjection.enforcement_percentage = %v; must be <= 100\", lbCfg.SuccessRateEjection.EnforcementPercentage)\n\tcase lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.Threshold > 100:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.threshold = %v; must be <= 100\", lbCfg.FailurePercentageEjection.Threshold)\n\tcase lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.EnforcementPercentage > 100:\n\t\treturn nil, fmt.Errorf(\"OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.enforcement_percentage = %v; must be <= 100\", lbCfg.FailurePercentageEjection.EnforcementPercentage)\n\t}\n\treturn lbCfg, nil\n}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/balancer/outlierdetection/balancer.go#L117-L153","documentation":"Returned by outlier detection ParseConfig (internal/xds/balancer/outlierdetection/balancer.go:134) when the LBConfig `max_ejection_time` Duration field is negative. gRFC A50 requires this field to be non-negative; the default is 300s. It caps the computed ejection time so a large ejectionTimeMultiplier cannot eject an endpoint indefinitely.","triggerScenarios":"ParseConfig gets JSON whose `max_ejection_time` decodes to a negative Duration. Comes from hand-built configs, a buggy resolver, or a control plane emitting negative protobuf seconds.","commonSituations":"Control-plane typo sending a negative max ejection time; test configs with invalid durations; negative seconds from a bad Duration serialization.","solutions":["Set `max_ejection_time` to a non-negative Duration (omit to accept the 300s default)","Correct the upstream xDS OutlierDetection resource","Validate the policy before publishing it to the control plane"],"exampleFix":"// before\n{\"maxEjectionTime\":\"-300s\"}\n// after\n{\"maxEjectionTime\":\"300s\"}","handlingStrategy":"validation","validationCode":"var probe struct{ MaxEjectionTime string `json:\"max_ejection_time\"` }\n_ = json.Unmarshal(raw, &probe)\nif probe.MaxEjectionTime != \"\" {\n    d, err := time.ParseDuration(probe.MaxEjectionTime)\n    if err != nil || d < 0 {\n        return fmt.Errorf(\"max_ejection_time must be >= 0, got %q\", probe.MaxEjectionTime)\n    }\n}","typeGuard":null,"tryCatchPattern":"lbCfg, err := outlierBB.ParseConfig(raw)\nif err != nil {\n    logger.Warningf(\"rejecting outlier detection config: %v\", err)\n    return fallbackLBConfig\n}","preventionTips":["Keep max_ejection_time >= base_ejection_time for sane behavior","Emit non-negative durations","Omit the field to use the 300s default"],"tags":["grpc","xds","outlier-detection","load-balancing","config","go"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}