{"record":{"id":"681efbb976ce8b11","repo":"App-vNext/Polly","slug":"the-retry-backoff-type-is-not-supported","errorCode":null,"errorMessage":"The retry backoff type is not supported.","messagePattern":"The retry backoff type is not supported\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Polly.Core/Retry/RetryHelper.cs","lineNumber":127,"sourceCode":"\n        return TimeSpan.FromTicks(ticks);\n    }\n\n    private static TimeSpan GetRetryDelayCore(DelayBackoffType type, bool jitter, int attempt, TimeSpan baseDelay, ref double state, Func<double> randomizer)\n    {\n        if (baseDelay == TimeSpan.Zero)\n        {\n            return baseDelay;\n        }\n\n        if (jitter)\n        {\n            return type switch\n            {\n                DelayBackoffType.Constant => ApplyJitter(baseDelay, randomizer),\n                DelayBackoffType.Linear => ApplyJitter(TimeSpan.FromMilliseconds((attempt + 1) * baseDelay.TotalMilliseconds), randomizer),\n                DelayBackoffType.Exponential => DecorrelatedJitterBackoffV2(attempt, baseDelay, ref state, randomizer),\n                _ => throw new ArgumentOutOfRangeException(nameof(type), type, \"The retry backoff type is not supported.\")\n            };\n        }\n\n        return type switch\n        {\n            DelayBackoffType.Constant => baseDelay,\n#if !NETCOREAPP\n            DelayBackoffType.Linear => TimeSpan.FromMilliseconds((attempt + 1) * baseDelay.TotalMilliseconds),\n            DelayBackoffType.Exponential => TimeSpan.FromMilliseconds(Math.Pow(ExponentialFactor, attempt) * baseDelay.TotalMilliseconds),\n#else\n            DelayBackoffType.Linear => (attempt + 1) * baseDelay,\n            DelayBackoffType.Exponential => Math.Pow(ExponentialFactor, attempt) * baseDelay,\n#endif\n            _ => throw new ArgumentOutOfRangeException(nameof(type), type, \"The retry backoff type is not supported.\")\n        };\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly.Core/Retry/RetryHelper.cs#L109-L145","documentation":"In the jitter branch of RetryHelper.GetRetryDelayCore, the switch over DelayBackoffType throws ArgumentOutOfRangeException for any value outside Constant/Linear/Exponential. It is a defensive exhaustiveness check: the public enum only defines those three members, so this fires if an invalid cast or future enum member is passed, or if reflection supplies an undefined enum value.","triggerScenarios":"Passing an undefined DelayBackoffType value (e.g. (DelayBackoffType)99) into RetryStrategyOptions.BackoffType and enabling jitter, then triggering a retry. Normally the options validator rejects invalid enum values first; this throw is the last line of defense.","commonSituations":"Reading backoff type from configuration with a typo that fails to parse and defaults oddly; casting an int to DelayBackoffType without validation; reflection/serialization round-trip producing an undefined value.","solutions":["Use one of the documented DelayBackoffType members (Constant, Linear, Exponential) when configuring RetryStrategyOptions.BackoffType.","Validate configuration-bound enum values with Enum.IsDefined before assigning.","If parsing from config, map string keys to the enum explicitly and reject unknown strings."],"exampleFix":"// before\noptions.BackoffType = (DelayBackoffType)99; // undefined\noptions.UseJitter = true;\n\n// after\noptions.BackoffType = DelayBackoffType.Exponential;\noptions.UseJitter = true;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(DelayBackoffType), value)) {\n    throw new ArgumentOutOfRangeException(nameof(value), \"Undefined DelayBackoffType.\");\n}\noptions.BackoffType = value;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assign only Constant/Linear/Exponential to RetryStrategyOptions.BackoffType.","Validate config-bound enums with Enum.IsDefined before assignment.","Map config strings to enum values explicitly and reject unknown names."],"tags":["retry","backoff","enum","argument-out-of-range","defensive","polly-core"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}