{"record":{"id":"596856ea0f67db17","repo":"iOfficeAI/OfficeCLI","slug":"invalid-reflection-value-value-valid-preset","errorCode":null,"errorMessage":"Invalid 'reflection' value '{value}'. Valid presets: none, tight, small, half, true, full; or a numeric percentage 0-100.","messagePattern":"Invalid 'reflection' value '(.+?)'\\. Valid presets: none, tight, small, half, true, full; or a numeric percentage 0-100\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"src/officecli/Core/DrawingEffectsHelper.cs","lineNumber":141,"sourceCode":"\n    /// <summary>\n    /// Build a Reflection element from a value string.\n    /// Values: \"tight\"/\"small\", \"half\"/\"true\", \"full\", or numeric percentage.\n    /// </summary>\n    public static Drawing.Reflection BuildReflection(string value)\n    {\n        // Unknown preset names (and out-of-range numerics) used to silently\n        // fall back to \"half\" (90000), masking typos. Reject so the caller\n        // surfaces the value rather than writing a no-op effect.\n        int endPos;\n        switch (value.ToLowerInvariant())\n        {\n            case \"tight\": case \"small\": endPos = 55000; break;\n            case \"true\":  case \"half\":  endPos = 90000; break;\n            case \"full\":               endPos = 100000; break;\n            default:\n                if (!int.TryParse(value, out var pct) || pct < 0 || pct > 100)\n                    throw new ArgumentException(\n                        $\"Invalid 'reflection' value '{value}'. Valid presets: none, tight, small, half, true, full; or a numeric percentage 0-100.\");\n                endPos = (int)Math.Min((long)pct * 1000, 100000);\n                break;\n        }\n\n        return new Drawing.Reflection\n        {\n            BlurRadius = 6350,\n            StartOpacity = 52000,\n            StartPosition = 0,\n            EndAlpha = 300,\n            EndPosition = endPos,\n            Distance = 0,\n            Direction = 5400000,\n            VerticalRatio = -100000,\n            Alignment = Drawing.RectangleAlignmentValues.BottomLeft,\n            RotateWithShape = false\n        };","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/DrawingEffectsHelper.cs#L123-L159","documentation":"BuildReflection parses the reflection value: named presets (tight/small=true/half/full, plus implicit none) map to fixed endPos values; anything else must be an integer percentage 0..100. An unrecognized preset AND a non-integer/out-of-range number is rejected, so a typo no longer silently falls back to 'half'.","triggerScenarios":"A reflection value that is neither a known preset nor a valid percentage: 'refelct' (typo), 'medium', 'half-full', '150' (>100), '-5' (<0), 'abc'.","commonSituations":"Typo in a preset name; using a word the UI shows but this API doesn't accept; a percentage outside 0..100; a locale-specific decimal separator ('50,5').","solutions":["Use a documented preset: none, tight, small, half (or true), full.","Or use an integer percentage 0..100.","Check spelling and remove stray suffixes/units."],"exampleFix":"// before — typo / out of range\neffect=\"reflection:mediuM\"\neffect=\"reflection:150\"\n\n// after\neffect=\"reflection:medium\"   // still invalid — use a preset:\neffect=\"reflection:half\"\neffect=\"reflection:50\"","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ReflectionPresets = new(StringComparer.OrdinalIgnoreCase)\n    { \"none\",\"tight\",\"small\",\"half\",\"true\",\"full\" };\nstatic bool IsValidReflection(string v)\n    => ReflectionPresets.Contains(v) || (int.TryParse(v, out var p) && p is >= 0 and <= 100);","typeGuard":null,"tryCatchPattern":"try { DrawingEffectsHelper.BuildReflection(value); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid 'reflection'\", StringComparison.Ordinal))\n{ errors.Add(ex.Message); }","preventionTips":["Use a documented preset or an integer percentage 0..100.","Don't rely on silent fallback — typos now throw.","Avoid locale decimal separators."],"tags":["reflection","effect","validation","user-input","drawing"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}