{"record":{"id":"835237c04fa8ebcc","repo":"glzr-io/glazewm","slug":"root-container-does-not-have-a-position","errorCode":null,"errorMessage":"Root container does not have a position.","messagePattern":"Root container does not have a position\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wm/src/models/root_container.rs","lineNumber":79,"sourceCode":"      .iter()\r\n      .map(CommonGetters::to_dto)\r\n      .try_collect()?;\r\n\r\n    Ok(ContainerDto::Root(RootContainerDto {\r\n      id: self.id(),\r\n      parent_id: None,\r\n      children,\r\n      child_focus_order: self.0.borrow().child_focus_order.clone().into(),\r\n    }))\r\n  }\r\n}\r\n\r\nimpl_container_debug!(RootContainer);\r\nimpl_common_getters!(RootContainer);\r\n\r\nimpl PositionGetters for RootContainer {\r\n  fn to_rect(&self) -> anyhow::Result<Rect> {\r\n    bail!(\"Root container does not have a position.\")\r\n  }\r\n}\r\n","sourceCodeStart":61,"sourceCodeEnd":82,"githubUrl":"https://github.com/glzr-io/glazewm/blob/5709ad0a3c7c386bbc3e38166a865ffc12937515/packages/wm/src/models/root_container.rs#L61-L82","documentation":"`RootContainer::to_rect` is an intentionally unimplemented operation. The root container sits at the top of the container hierarchy and has no parent or monitor geometry of its own, so any attempt to resolve its `Rect` is a logic error in the caller. The library bails unconditionally to catch code that wrongly assumes the root has a position.","triggerScenarios":"Calling `to_rect()` (directly or via position-dependent helpers like tiling-direction or monitor-lookup code) on a container that is actually the root, e.g. by walking up parent pointers past the last monitor without a bounds check.","commonSituations":"Window-management scripts or internal command handling that iterates ancestor containers and calls `to_rect()` on each; refactorings where a loop's stop condition at the root was removed or a `Container::root()` is accidentally treated as a normal node.","solutions":["Check `container.is_root()` (or the container type/kind) before calling `to_rect()` and handle the root specially.","Stop ancestor traversal before reaching the root (e.g. `while let Some(parent) = container.parent() { if parent.is_root() { break; } ... }`).","If the caller needs a full-workspace rect, derive it from the monitor's `to_rect()` instead of the root.","Match on the container variant and only call `to_rect()` on non-root containers.","If hit inside wm itself, report as a bug: the root should never be passed to position-dependent code."],"exampleFix":"// before\nlet rect = container.to_rect()?;\n// after\nif container.is_root() {\n  anyhow::bail!(\"Cannot compute rect for root container.\");\n}\nlet rect = container.to_rect()?;","handlingStrategy":"try-catch","validationCode":"fn can_get_rect(c: &Container) -> bool { !c.is_root() }","typeGuard":"fn is_root(c: &Container) -> bool { matches!(c, Container::Root(_)) }","tryCatchPattern":"let rect = match container.to_rect() {\n  Ok(r) => r,\n  Err(_) => return, // root container: no position\n};","preventionTips":["Always bound ancestor traversal before the root node.","Prefer monitor-level containers when you need geometry.","Add debug assertions that position-dependent code never receives the root."],"tags":["rust","window-manager","internal-invariant"],"backgroundTag":"unsupported-operation","analyzedSha":"5709ad0a3c7c386bbc3e38166a865ffc12937515","analyzedAt":"2026-09-08T03:26:40.288Z","contentChangedAt":"2026-09-08T03:26:40.288Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}