{"record":{"id":"83bc4535ef858987","repo":"d2phap/ImageGlass","slug":"optionstr-is-not-a-valid-flip-option","errorCode":null,"errorMessage":"'{optionStr}' is not a valid flip option.\n\n----------\n👉🏼 Method: IG_FlipImage","messagePattern":"'(.+?)' is not a valid flip option\\.\n\n----------\n👉🏼 Method: IG_FlipImage","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs","lineNumber":1825,"sourceCode":"            Core.ImageTransform.Rotation = currentRotation;\n        }\n        else\n        {\n            _ = Message.ShowAsync(\n                Core.Lang[LangId._InvalidAction_Transformation],\n                Core.Lang[LangId._InvalidAction]);\n        }\n    }\n\n\n    /// <summary>\n    /// Flips the current image according to the flip options.\n    /// </summary>\n    public void IG_FlipImage(string? optionStr)\n    {\n        if (!Enum.TryParse<FlipOptions>(optionStr, out var options))\n        {\n            throw new ArgumentException($\"\"\"\n                '{optionStr}' is not a valid flip option.\n\n                ----------\n                👉🏼 Method: {nameof(IG_FlipImage)}\n                \"\"\",\n                nameof(optionStr));\n        }\n\n        IG_FlipImage(options);\n    }\n\n\n    /// <summary>\n    /// Flips the current image according to the flip options.\n    /// </summary>\n    public static void IG_FlipImage(FlipOptions options)\n    {\n        if (Viewer.SourceKind == PhotoSource.None || Core.IsBusy) return;","sourceCodeStart":1807,"sourceCodeEnd":1843,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs#L1807-L1843","documentation":"Thrown by the string overload of IG_FlipImage when Enum.TryParse<FlipOptions>(optionStr) fails. FlipOptions is a [Flags] enum; valid names are None, Horizontal, and Vertical. Combinations like 'Horizontal,Vertical' are accepted case-insensitively. Any token not in the set fails the whole parse.","triggerScenarios":"Calling IG_FlipImage(string) with 'h'/'v', 'flip-h', 'both' (use 'Horizontal,Vertical'), 'horizontal ' with a trailing space inside the token, or 'mirror'.","commonSituations":"User types a short alias instead of the full name; config with a non-defined combination; trailing whitespace inside a comma list.","solutions":["Use None, Horizontal, Vertical, or a comma-separated combination such as 'Horizontal,Vertical'.","Validate with Enum.TryParse<FlipOptions> upstream and call the typed overload.","Trim each token in a comma-separated list before parsing."],"exampleFix":"// before\napi.IG_FlipImage(userInput);\n\n// after\nif (Enum.TryParse<FlipOptions>(userInput?.Trim(), true, out var opt))\n{\n    api.IG_FlipImage(opt);\n}","handlingStrategy":"validation","validationCode":"if (!Enum.TryParse<FlipOptions>(optionStr?.Trim(), true, out var opt))\n    throw new ArgumentException($\"Unknown flip option '{optionStr}'.\");\napi.IG_FlipImage(opt);","typeGuard":"static bool IsValidFlipOption(string? s) => Enum.TryParse<FlipOptions>(s?.Trim(), true, out _);","tryCatchPattern":"try { api.IG_FlipImage(optionStr); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(optionStr))\n{ /* valid: None, Horizontal, Vertical, or 'Horizontal,Vertical' */ }","preventionTips":["Use None, Horizontal, Vertical, or a comma-separated combination.","Trim each token in a comma-separated list before parsing.","Validate with Enum.TryParse<FlipOptions> before calling."],"tags":["app-api","flip","argument-parsing","enum","flags"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}