{"record":{"id":"189f35a6f8b2113b","repo":"grpc/grpc-go","slug":"outlierdetectionloadbalancingconfig-base-ejection","errorCode":null,"errorMessage":"OutlierDetectionLoadBalancingConfig.base_ejection_time = %s; must be >= 0","messagePattern":"OutlierDetectionLoadBalancingConfig\\.base_ejection_time = (.+?); must be >= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/outlierdetection/balancer.go","lineNumber":133,"sourceCode":"\t// Note: in the xds flow, these validations will never fail. The xdsclient\n\t// performs the same validations as here on the xds Outlier Detection\n\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","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/balancer/outlierdetection/balancer.go#L115-L151","documentation":"Returned by outlier detection ParseConfig (internal/xds/balancer/outlierdetection/balancer.go:132) when the LBConfig `base_ejection_time` Duration field is negative. Per gRFC A50 the field must be non-negative; the default is 30s when omitted. This is the same A50 non-negative check as interval, applied to the base ejection time used to compute how long an ejected endpoint stays ejected.","triggerScenarios":"ParseConfig receives JSON where `base_ejection_time` decodes to a negative time.Duration (e.g. \"-30s\"). Fires from hand-built configs, buggy resolvers, or a control plane sending a protobuf Duration with negative seconds.","commonSituations":"Control-plane misconfiguration of the outlier detection policy; test fixtures with copy-pasted negative values; protobuf Duration encoding bugs producing negative seconds.","solutions":["Set `base_ejection_time` to a non-negative Duration (omit to accept the 30s default)","Fix the xDS OutlierDetection resource supplying the bad value","Pre-validate durations in the config emitter"],"exampleFix":"// before\n{\"baseEjectionTime\":\"-30s\"}\n// after\n{\"baseEjectionTime\":\"30s\"}","handlingStrategy":"validation","validationCode":"var probe struct{ BaseEjectionTime string `json:\"base_ejection_time\"` }\n_ = json.Unmarshal(raw, &probe)\nif probe.BaseEjectionTime != \"\" {\n    d, err := time.ParseDuration(probe.BaseEjectionTime)\n    if err != nil || d < 0 {\n        return fmt.Errorf(\"base_ejection_time must be >= 0, got %q\", probe.BaseEjectionTime)\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":["Emit non-negative durations for all ejection timers","Pre-validate protobuf Duration seconds >= 0","Omit the field to use the 30s 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"}