d2phap/ImageGlass Β· error Β· ArgumentException
'{optionStr}' is not a valid flip option. ---------- ππΌ M
Error message
'{optionStr}' is not a valid flip option.
----------
ππΌ Method: IG_FlipImage What it means
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.
Source
Thrown at source/ImageGlass.Lib/Common/ServiceProviders/AppAPIs/AppAPIProvider.cs:1825
Core.ImageTransform.Rotation = currentRotation;
}
else
{
_ = Message.ShowAsync(
Core.Lang[LangId._InvalidAction_Transformation],
Core.Lang[LangId._InvalidAction]);
}
}
/// <summary>
/// Flips the current image according to the flip options.
/// </summary>
public void IG_FlipImage(string? optionStr)
{
if (!Enum.TryParse<FlipOptions>(optionStr, out var options))
{
throw new ArgumentException($"""
'{optionStr}' is not a valid flip option.
----------
ππΌ Method: {nameof(IG_FlipImage)}
""",
nameof(optionStr));
}
IG_FlipImage(options);
}
/// <summary>
/// Flips the current image according to the flip options.
/// </summary>
public static void IG_FlipImage(FlipOptions options)
{
if (Viewer.SourceKind == PhotoSource.None || Core.IsBusy) return;View on GitHub (pinned to 4a3c4fecef)
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.
Example fix
// before
api.IG_FlipImage(userInput);
// after
if (Enum.TryParse<FlipOptions>(userInput?.Trim(), true, out var opt))
{
api.IG_FlipImage(opt);
} Defensive patterns
Strategy: validation
Validate before calling
if (!Enum.TryParse<FlipOptions>(optionStr?.Trim(), true, out var opt))
throw new ArgumentException($"Unknown flip option '{optionStr}'.");
api.IG_FlipImage(opt); Type guard
static bool IsValidFlipOption(string? s) => Enum.TryParse<FlipOptions>(s?.Trim(), true, out _);
Try / catch
try { api.IG_FlipImage(optionStr); }
catch (ArgumentException ex) when (ex.ParamName == nameof(optionStr))
{ /* valid: None, Horizontal, Vertical, or 'Horizontal,Vertical' */ } Prevention
- 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.
When it happens
Trigger: Calling IG_FlipImage(string) with 'h'/'v', 'flip-h', 'both' (use 'Horizontal,Vertical'), 'horizontal ' with a trailing space inside the token, or 'mirror'.
Common situations: User types a short alias instead of the full name; config with a non-defined combination; trailing whitespace inside a comma list.
Related errors
- '{channelsStr}' is not a valid color channel. ---------- π
- '{modeStr}' is not a valid zoom mode. ---------- ππΌ Metho
- '{orderByStr}' is not a valid loading order. ---------- ποΏ½
- '{orderTypeStr}' is not a valid loading order. ---------- οΏ½
- '{optionStr}' is not a valid rotation option. ---------- π
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/83bc4535ef858987.
Report an issue: GitHub.