{"record":{"id":"37d9322233a2cbf9","repo":"Hmbown/CodeWhale","slug":"runtime-store-root-cannot-be-empty","errorCode":null,"errorMessage":"Runtime store root cannot be empty","messagePattern":"Runtime store root cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13689,"sourceCode":"        0\n    } else {\n        u64::try_from(millis).unwrap_or(u64::MAX)\n    }\n}\n\nfn panic_payload_message(payload: &(dyn std::any::Any + Send)) -> String {\n    if let Some(message) = payload.downcast_ref::<&str>() {\n        (*message).to_string()\n    } else if let Some(message) = payload.downcast_ref::<String>() {\n        message.clone()\n    } else {\n        \"unknown panic payload\".to_string()\n    }\n}\n\nfn checked_runtime_store_root(root: PathBuf) -> Result<PathBuf> {\n    if root.as_os_str().is_empty() {\n        bail!(\"Runtime store root cannot be empty\");\n    }\n    if root\n        .components()\n        .any(|component| matches!(component, Component::ParentDir))\n    {\n        bail!(\"Runtime store root cannot contain '..' components\");\n    }\n    let absolute = if root.is_absolute() {\n        root\n    } else {\n        std::env::current_dir()\n            .context(\"failed to resolve current directory for runtime store\")?\n            .join(root)\n    };\n    match absolute.canonicalize() {\n        Ok(path) => Ok(path),\n        Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n            Ok(normalize_path_components(&absolute))","sourceCodeStart":13671,"sourceCodeEnd":13707,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13671-L13707","documentation":"checked_runtime_store_root validates the configured runtime store root before use. An empty path cannot be resolved into a valid store location, so it is rejected eagerly. This is fail-loud validation of a misconfiguration.","triggerScenarios":"Constructing/opening the runtime store with an empty PathBuf (e.g. from an unset config value mapped to PathBuf::new(), or an empty CLI/env string).","commonSituations":"Config key for the store root present but empty string; env var unset parsed into an empty path; programmatically passing PathBuf::new() as a default.","solutions":["Set the runtime store root to an absolute directory in config/CLI/env","Reject empty store-root strings at config-load time with a clear message","Fall back to a documented default directory instead of an empty path"],"exampleFix":"// before\nlet root: PathBuf = std::env::var(\"RUNTIME_STORE\").unwrap_or_default().into(); // empty when unset\n// after\nlet root: PathBuf = std::env::var(\"RUNTIME_STORE\").context(\"RUNTIME_STORE must be set\")?.into();","handlingStrategy":"validation","validationCode":"fn store_root_ok(p: &Path) -> bool { !p.as_os_str().is_empty() }","typeGuard":"fn non_empty(p: &Path) -> Option<&Path> { (!p.as_os_str().is_empty()).then_some(p) }","tryCatchPattern":"match store.open(root).await {\n    Err(e) if e.to_string().contains(\"cannot be empty\") => {\n        let root = default_store_root()?;\n        store.open(root).await?\n    }\n    other => other?,\n}","preventionTips":["Use Option<PathBuf> for optional store roots instead of empty PathBuf","Reject empty strings at config parse time","Provide a non-empty default store directory"],"tags":["config","path","validation"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}