{"record":{"id":"338384fbe3857df9","repo":"stride3d/stride","slug":"owner-s-fieldname-must-be-finite-and-greater-than-zero","errorCode":null,"errorMessage":"{owner}'s {fieldName} must be finite and greater than zero","messagePattern":"(.+?)'s (.+?) must be finite and greater than zero","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/BepuAndStrideExtensions.cs","lineNumber":56,"sourceCode":"    [MethodImpl(MethodImplOptions.AggressiveInlining)]\n    public static void ValidateRange<T>(this SVector3 vec, T owner, [CallerMemberName] string? fieldName = null)\n    {\n        if (NVector3.AllWhereAllBitsSet(NVector3.IsFinite(vec)) == false)\n            throw new ArgumentOutOfRangeException($\"{owner}'s {fieldName} must be finite\");\n    }\n\n    [MethodImpl(MethodImplOptions.AggressiveInlining)]\n    public static void ValidateRange<T>(this SQuaternion quat, T owner, [CallerMemberName] string? fieldName = null)\n    {\n        if (quat.IsNormalized == false)\n            throw new ArgumentOutOfRangeException($\"{owner}'s {fieldName} must be normalized\");\n    }\n\n    [MethodImpl(MethodImplOptions.AggressiveInlining)]\n    public static void ValidateGreaterThanZeroFinite<T>(this float fp, T owner, [CallerMemberName] string? fieldName = null)\n    {\n        if (fp <= 0 || float.IsFinite(fp) == false)\n            throw new ArgumentOutOfRangeException($\"{owner}'s {fieldName} must be finite and greater than zero\");\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":59,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/BepuAndStrideExtensions.cs#L38-L59","documentation":"ValidateGreaterThanZeroFinite validates that a float handed to the physics layer is both finite (not NaN/Infinity) and strictly greater than zero. Quantities like radius, size, or stiffness must be positive for shape construction and solver stability, so violations throw ArgumentOutOfRangeException with owner and field context.","triggerScenarios":"Setting a scalar physics property (e.g. SphereCollider radius, capsule length) to 0, a negative number, float.PositiveInfinity, or NaN — commonly from an uninitialized field or division by zero upstream.","commonSituations":"Reading collider dimensions from model/config data containing zeros; computing radius from bounds of an empty mesh; default(float) (0) accidentally passed through.","solutions":["Clamp before assigning: value = MathF.Max(MathF.Min(value, max), 1e-6f) after confirming it's finite.","Fix the upstream computation or data source producing 0/NaN/Infinity.","Validate configuration/deserialized values at load time and substitute sane defaults."],"exampleFix":"// before\nsphere.Radius = computedRadius; // could be 0 or NaN\n// after\nvar r = float.IsFinite(computedRadius) && computedRadius > 0 ? computedRadius : 0.5f;\nsphere.Radius = r;","handlingStrategy":"validation","validationCode":"bool IsValidScalar(float v) => float.IsFinite(v) && v > 0;\nif (!IsValidScalar(radius)) radius = 1e-3f; // or throw","typeGuard":null,"tryCatchPattern":"try { fp.ValidateGreaterThanZeroFinite(this); prop = fp; } catch (ArgumentOutOfRangeException ex) { log.Error($\"Invalid scalar for {ex.ParamName}\", ex); }","preventionTips":["Clamp all physics scalars to a small positive minimum","Validate model/config-derived dimensions right after load","Never assign default(float) or unset fields to physics size properties"],"tags":["physics","validation","argument"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}