{"record":{"id":"8722889b4bed31cb","repo":"astrid-runtime/astrid","slug":"read-e","errorCode":null,"errorMessage":"read {}: {e}","messagePattern":"read (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-daemon/src/lib.rs","lineNumber":486,"sourceCode":"#[expect(\n    clippy::unused_async,\n    reason = \"the cross-platform daemon entry point remains async even when startup is unsupported\"\n)]\npub async fn run() -> Result<()> {\n    anyhow::bail!(\"native Astrid daemon startup is not yet supported on this platform\")\n}\n\n/// Load `etc/gateway-http.toml`. Returns `Ok(None)` when the file\n/// doesn't exist (single-tenant default).\n#[cfg(unix)]\nasync fn load_gateway_config() -> Result<Option<astrid_gateway::GatewayConfig>> {\n    let home = astrid_core::dirs::AstridHome::resolve()\n        .map_err(|e| anyhow::anyhow!(\"resolve AstridHome: {e}\"))?;\n    let path = home.etc_dir().join(\"gateway-http.toml\");\n    let text = match tokio::fs::read_to_string(&path).await {\n        Ok(b) => b,\n        Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None),\n        Err(e) => return Err(anyhow::anyhow!(\"read {}: {e}\", path.display())),\n    };\n    let cfg: astrid_gateway::GatewayConfig =\n        toml::from_str(&text).context(\"parse gateway-http.toml\")?;\n    cfg.validate().context(\"validate gateway-http.toml\")?;\n    Ok(Some(cfg))\n}\n\n#[cfg(unix)]\nfn spawn_gateway(\n    cfg: astrid_gateway::GatewayConfig,\n    kernel: &std::sync::Arc<astrid_kernel::Kernel>,\n) -> Result<std::sync::Arc<tokio::sync::Notify>> {\n    // Plumb four kernel handles into the gateway:\n    //\n    //   * the event bus, so the SSE audit stream and the bus-direct\n    //     admin client can subscribe / publish locally without going\n    //     back over the Unix socket;\n    //   * the persistent audit log, so the new","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-daemon/src/lib.rs#L468-L504","documentation":"`load_gateway_config` reads `<astrid-home>/etc/gateway-http.toml` with `tokio::fs::read_to_string`. A NotFound error is tolerated (single-tenant default, Ok(None)), but any other I/O error — permission denied, is-a-directory, invalid UTF-8 — is propagated as `read <path>: <cause>`.","triggerScenarios":"Calling `load_gateway_config()` when gateway-http.toml exists but cannot be read: wrong permissions, path is a directory, or file contains invalid UTF-8.","commonSituations":"Tightened permissions after an audit; a directory accidentally named gateway-http.toml; editor saving the file in a non-UTF-8 encoding.","solutions":["Read the wrapped path and io error to see exactly what failed.","Fix permissions so the daemon user can read `<home>/etc/gateway-http.toml`.","If the path is a directory or has bad encoding, remove/recreate it as a UTF-8 TOML file.","If you don't need the gateway config, delete the file — absence is the supported single-tenant default."],"exampleFix":"// before\n$ ls -l ~/.astrid/etc/gateway-http.toml\n-rw------- root root\n// after\n$ sudo chown astrid:astrid ~/.astrid/etc/gateway-http.toml\n$ chmod 600 ~/.astrid/etc/gateway-http.toml","handlingStrategy":"try-catch","validationCode":"// shell\nF=\"$HOME/.astrid/etc/gateway-http.toml\"\nif [ -e \"$F\" ]; then [ -f \"$F\" ] && [ -r \"$F\" ] && iconv -f utf-8 -t utf-8 \"$F\" >/dev/null || exit 1; fi","typeGuard":null,"tryCatchPattern":"// rust\nmatch load_gateway_config().await {\n    Ok(None) => { /* no file: use single-tenant default */ }\n    Ok(Some(cfg)) => { /* use cfg */ }\n    Err(e) => { eprintln!(\"{e:#}\"); /* path and io cause are in the message */ }\n}","preventionTips":["Keep gateway-http.toml a regular, daemon-readable UTF-8 file.","Never name a directory gateway-http.toml.","Delete the file if you want the single-tenant default instead of fixing permissions."],"tags":["filesystem","config","io"],"backgroundTag":"file-read-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}