glzr-io/glazewm · error
Not a valid tiling direction
Error message
Not a valid tiling direction: {} What it means
`TilingDirection::from_str` parses a user-supplied string into the `TilingDirection` enum. It only accepts the exact literals "horizontal" and "vertical"; any other string makes it bail with this message including the offending input.
Solutions
- Use exactly "horizontal" or "vertical", all lowercase, no surrounding whitespace
- Call `.trim().to_lowercase()` on the input before parsing
- Match on the valid variants via `TilingDirection::iter()` or check the enum definition in packages/wm-common/src/tiling_direction.rs
Example fix
// before let dir = "Horizontal".parse::<TilingDirection>()?; // after let dir = "horizontal".parse::<TilingDirection>()?;
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_tiling_direction(s: &str) -> bool {
matches!(s.trim().to_lowercase().as_str(), "horizontal" | "vertical")
} Type guard
fn as_tiling_direction(s: &str) -> Option<TilingDirection> {
match s.trim().to_lowercase().as_str() {
"horizontal" => Some(TilingDirection::Horizontal),
"vertical" => Some(TilingDirection::Vertical),
_ => None,
}
} Try / catch
match "Horizontal".parse::<TilingDirection>() {
Ok(dir) => use_dir(dir),
Err(e) => eprintln!("invalid tiling direction: {e}"),
} Prevention
- Normalize user input with trim().to_lowercase() before parsing
- Keep direction strings centralized in config constants
- Validate config values at load time with clear diagnostics
When it happens
Trigger: Calling `"left".parse::<TilingDirection>()`, `TilingDirection::from_str("Horizontal")` (case mismatch), or binding a WM config/IPC value like "horiz" or "h" to a tiling direction.
Common situations: Typos in GlazeWM config files or IPC commands (e.g. `tiling_direction: horizontal ` with trailing whitespace, capitalized text, or translated values in keybinding definitions).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Shell exec failed for
- Shell exec failed for
- The workspace " " already exists
- Invalid tray menu event
- Shell exec failed for
AI-assisted analysis of glzr-io/glazewm@5709ad0a3c (2026-09-08).
Data as JSON: /api/errors/38dc10ad18b90888.
Report an issue: GitHub.
Appendix: source
Thrown at packages/wm-common/src/tiling_direction.rs:69
type Err = anyhow::Error;
/// Parses a string into a tiling direction.
///
/// Example:
/// ```
/// # use wm_common::TilingDirection;
/// # use std::str::FromStr;
/// let dir = TilingDirection::from_str("horizontal");
/// assert_eq!(dir.unwrap(), TilingDirection::Horizontal);
///
/// let dir = TilingDirection::from_str("vertical");
/// assert_eq!(dir.unwrap(), TilingDirection::Vertical);
/// ```
fn from_str(unparsed: &str) -> anyhow::Result<Self> {
match unparsed {
"horizontal" => Ok(Self::Horizontal),
"vertical" => Ok(Self::Vertical),
_ => bail!("Not a valid tiling direction: {}", unparsed),
}
}
}
View on GitHub (pinned to 5709ad0a3c)