{"record":{"id":"7a28766f47a47724","repo":"stride3d/stride","slug":"radius-cannot-be-0","errorCode":null,"errorMessage":"Radius cannot be < 0","messagePattern":"Radius cannot be < 0","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/BokehTechnique/BokehBlur.cs","lineNumber":59,"sourceCode":"\n        /// <summary>\n        /// Sets the radius of the blur.\n        /// A child class can override it to do special processing when a new value is provided.\n        /// </summary>\n        /// <param name=\"value\">The new value of the blur.</param>\n        [DataMemberIgnore]\n        public virtual float Radius\n        {\n            get\n            {\n                return radius;\n            }\n\n            set\n            {\n                if (value < 0f)\n                {\n                    throw new ArgumentOutOfRangeException(\"Radius cannot be < 0\");\n                }\n                if (value < 1f)\n                {\n                    // We need at least a radius of 1 texel to perform a blur. \n                    value = 1f;\n                }\n                this.radius = value;\n            }\n        }\n    }\n}\n","sourceCodeStart":41,"sourceCodeEnd":71,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/BokehTechnique/BokehBlur.cs#L41-L71","documentation":"The Radius property setter of BokehBlur (depth-of-field bokeh technique) throws ArgumentOutOfRangeException when a negative value is assigned. Values below 1 are silently clamped to 1 texel because at least one texel radius is required to perform a blur, but negative values are rejected outright.","triggerScenarios":"Assigning bokehBlur.Radius = -1 (or any negative float), usually from a computed value such as a scaled focus parameter or user input that wasn't clamped.","commonSituations":"Camera focus/blur configuration driven by UI sliders allowing negatives; computations like radius = someScale * factor that can yield negative results; config files with negative radius entries.","solutions":["Clamp the radius with Math.Max(0f, radius) before assigning.","Validate user-facing input so the radius can never go negative.","Note values in [0,1) are auto-clamped to 1 by the setter, so only negatives need guarding."],"exampleFix":"// before\nbokeh.Radius = computedRadius; // can be negative\n// after\nbokeh.Radius = MathF.Max(0f, computedRadius);","handlingStrategy":"validation","validationCode":"float safeRadius = Math.Clamp(radius, 0f, float.MaxValue);\nbokeh.Radius = safeRadius;","typeGuard":"bool IsValidRadius(float r) => !float.IsNaN(r) && !float.IsInfinity(r) && r >= 0f;","tryCatchPattern":"try { bokeh.Radius = r; }\ncatch (ArgumentOutOfRangeException ex) { bokeh.Radius = 1f; Log.Warn(ex, \"Radius clamped\"); }","preventionTips":["Clamp computed radii to non-negative values","Constrain UI sliders to 0..max range","Validate config-file radius values at load time"],"tags":["argument-out-of-range","radius","depth-of-field"],"backgroundTag":"value-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}