{"record":{"id":"7b93aef5a3d04faa","repo":"elkowar/eww","slug":"no-root-scope-in-graph","errorCode":null,"errorMessage":"No root scope in graph","messagePattern":"No root scope in graph","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/state/scope_graph.rs","lineNumber":136,"sourceCode":"    pub fn visualize(&self) -> String {\n        self.graph.visualize()\n    }\n\n    pub fn currently_used_globals(&self) -> HashSet<VarName> {\n        self.variables_used_in_self_or_subscopes_of(self.root_index)\n    }\n\n    pub fn currently_unused_globals(&self) -> HashSet<VarName> {\n        let used_variables = self.currently_used_globals();\n        self.global_scope().data.keys().cloned().collect::<HashSet<_>>().difference(&used_variables).cloned().collect()\n    }\n\n    pub fn scope_at(&self, index: ScopeIndex) -> Option<&Scope> {\n        self.graph.scope_at(index)\n    }\n\n    pub fn global_scope(&self) -> &Scope {\n        self.graph.scope_at(self.root_index).expect(\"No root scope in graph\")\n    }\n\n    /// Evaluate a [SimplExpr] in a given scope. This will return `Err` if any referenced variables\n    /// are not available in the scope. If evaluation fails for other reasons (bad types, etc)\n    /// this will print a warning and return an empty string instead.\n    pub fn evaluate_simplexpr_in_scope(&self, index: ScopeIndex, expr: &SimplExpr) -> Result<DynVal> {\n        let needed_vars = self.lookup_variables_in_scope(index, &expr.collect_var_refs())?;\n        // TODORW\n        // TODO allowing it to fail here is painfully ugly\n        match expr.eval(&needed_vars) {\n            Ok(value) => Ok(value),\n            Err(err) => {\n                error_handling_ctx::print_error(anyhow!(err));\n                Ok(DynVal::from(\"\"))\n            }\n        }\n    }\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/state/scope_graph.rs#L118-L154","documentation":"scope_graph.global_scope() indexes the graph at root_index and expects the scope to exist. If the root scope is missing, the scope graph was built or mutated incorrectly — again an internal invariant failure rather than something a config value directly controls.","triggerScenarios":"Calling global_scope() (directly or via currently_unused_globals) on a ScopeGraph whose root_index does not resolve, e.g. a graph constructed from an empty/failed parse where the root scope was never inserted or was removed.","commonSituations":"Seen during config parsing/reload when the widget hierarchy failed to build (malformed yuck XML) so the root scope never got created, or during teardown/rebuild races on hot reload.","solutions":["Fix the config error that prevented the root scope from being created: run `eww logs` and validate the yuck file (`xmllint` on widget XML).","Restart the daemon (`eww kill && eww daemon`) to rebuild the scope graph from scratch.","Update eww — if the graph constructor can produce a missing root, it is a bug worth reporting upstream.","Guard the accessor: return a Result or fall back to an empty scope instead of expecting."],"exampleFix":"// before\npub fn global_scope(&self) -> &Scope {\n    self.graph.scope_at(self.root_index).expect(\"No root scope in graph\")\n}\n// after\npub fn global_scope(&self) -> Result<&Scope> {\n    self.graph.scope_at(self.root_index).context(\"No root scope in graph\")\n}","handlingStrategy":"validation","validationCode":"// verify the graph root exists before use\nif graph.scope_at(graph.root_index).is_none() { return Err(anyhow!(\"scope graph has no root; config failed to parse\")); }","typeGuard":null,"tryCatchPattern":"match scope_graph.global_scope_checked() {\n    Ok(root) => /* use root */,\n    Err(e) => log::error!(\"scope graph unusable: {} — fix config and restart daemon\", e),\n}","preventionTips":["Validate yuck config before hot reload (eww logs / xmllint)","Ensure the root scope is always inserted at graph construction","Restart daemon after any scope-graph error instead of continuing on a broken graph","Add a unit test that every constructed ScopeGraph resolves root_index"],"tags":["scope-graph","internal-invariant","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}