{"record":{"id":"d39e74a649d68a03","repo":"d2phap/ImageGlass","slug":"step-stepstr-is-not-a-valid-integer","errorCode":null,"errorMessage":"Step '{stepStr}' is not a valid integer.\n\n----------\n👉🏼 Method: IG_ViewByStep","messagePattern":"Step '(.+?)' is not a valid integer\\.\n\n----------\n👉🏼 Method: IG_ViewByStep","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs","lineNumber":901,"sourceCode":"    /// View a photo in the list by the given index.\n    /// </summary>\n    public void IG_ViewByIndex(int photoIndex)\n    {\n        if (photoIndex < 0) return;\n\n        var step = photoIndex - Core.Photos.CurrentIndex;\n        IG_ViewByStep(step);\n    }\n\n\n    /// <summary>\n    /// View a photo in the list by the given step.\n    /// </summary>\n    public void IG_ViewByStep(string? stepStr)\n    {\n        if (!int.TryParse(stepStr, out var step))\n        {\n            throw new ArgumentException($\"\"\"\n                Step '{stepStr}' is not a valid integer.\n\n                ----------\n                👉🏼 Method: {nameof(IG_ViewByStep)}\n                \"\"\",\n                nameof(stepStr));\n        }\n\n        IG_ViewByStep(step);\n    }\n\n\n    /// <summary>\n    /// View a photo in the list by the given step.\n    /// </summary>\n    public void IG_ViewByStep(int step)\n    {\n        // Sequential mode: ignore navigation until the current photo is painted, so holding","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs#L883-L919","documentation":"Thrown by the string overload of IG_ViewByStep when int.TryParse(stepStr) fails. The method parses a navigation step (positive = forward, negative = backward) from a string before delegating to the int overload. A null or non-integer string raises ArgumentException naming the parameter.","triggerScenarios":"Calling IG_ViewByStep(string) with a non-numeric string: 'next', '+1', '1.0', '' (note: empty string fails TryParse), or a value with a leading/trailing space.","commonSituations":"Hotkey or CLI argument passed as a word rather than a number; config file with a quoted string; user-typed input in a custom command that was not sanitized.","solutions":["Pass a plain integer string such as '1', '-1', '5' (no plus sign, no decimals, no surrounding spaces).","Validate with int.TryParse before calling and use the int overload directly.","Trim whitespace and reject empty input upstream."],"exampleFix":"// before\napi.IG_ViewByStep(userInput);\n\n// after\nif (int.TryParse(userInput?.Trim(), out var step))\n{\n    api.IG_ViewByStep(step);\n}","handlingStrategy":"validation","validationCode":"if (!int.TryParse(stepStr?.Trim(), out var step))\n    throw new ArgumentException(\"Step must be an integer.\");\napi.IG_ViewByStep(step);","typeGuard":"static bool IsValidStep(string? s) => int.TryParse(s?.Trim(), out _);","tryCatchPattern":"try { api.IG_ViewByStep(stepStr); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(stepStr))\n{ /* reject the input, prompt again */ }","preventionTips":["Pass plain integer strings without '+', decimals, or surrounding spaces.","Validate upstream with int.TryParse and call the int overload.","Trim user input before parsing."],"tags":["app-api","navigation","argument-parsing","integer"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}