{"record":{"id":"51eac8468d9c640f","repo":"linera-io/linera-protocol","slug":"unable-to-read-the-configuration-file","errorCode":null,"errorMessage":"Unable to read the configuration file","messagePattern":"Unable to read the configuration file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-exporter/src/main.rs","lineNumber":238,"sourceCode":"    }\n}\n\nimpl RunOptions {\n    #[cfg(with_metrics)]\n    fn enable_memory_profiling(&self) -> bool {\n        #[cfg(feature = \"jemalloc\")]\n        {\n            self.enable_memory_profiling\n        }\n        #[cfg(not(feature = \"jemalloc\"))]\n        {\n            false\n        }\n    }\n\n    fn run(&self) -> anyhow::Result<()> {\n        let config_string = fs_err::read_to_string(&self.config_path)\n            .expect(\"Unable to read the configuration file\");\n        let mut config: BlockExporterConfig =\n            toml::from_str(&config_string).expect(\"Invalid configuration file format\");\n\n        let node_options = NodeOptions {\n            send_timeout: self.send_timeout,\n            recv_timeout: self.recv_timeout,\n            retry_delay: self.retry_delay,\n            max_retries: self.max_retries,\n            max_backoff: self.max_backoff,\n        };\n\n        if let Some(port) = self.metrics_port {\n            if IS_WITH_METRICS {\n                tracing::info!(\"overriding metrics port to {}\", port);\n                config.metrics_port = port;\n            } else {\n                tracing::warn!(\n                    \"Metrics are not enabled in this build, ignoring metrics port configuration.\"","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-exporter/src/main.rs#L220-L256","documentation":"linera-exporter's RunOptions::run (linera-exporter/src/main.rs:236) reads the TOML config file at --config with fs_err::read_to_string and panics if the read fails. Although run returns anyhow::Result, this particular failure is an expect, so a missing or unreadable config file crashes the process with a panic instead of a clean error. Causes: nonexistent path, wrong path, permission denied, or the path pointing at a directory.","triggerScenarios":"Starting the block exporter with `linera-exporter run --config <path>` where <path> does not exist, is not readable by the current user, is a directory, or a relative path resolved from a different working directory.","commonSituations":"Typo'd or stale config path in a systemd unit or container entrypoint; config file not mounted into the container; running from a different cwd so the relative path misses; file owned by root while the exporter runs as another user.","solutions":["Verify the path exists and is readable before launch: `test -r /path/to/exporter.toml && echo ok`.","Use an absolute path for --config in service definitions, containers, and scripts.","Check ownership/permissions (chown/chmod) if the exporter runs as a non-root user.","Confirm the file is a regular file, not a directory or a broken symlink."],"exampleFix":"# before\nlinera-exporter run --config exporter.toml   # panics if missing from this cwd\n\n# after\nCONFIG=/etc/linera/exporter.toml\ntest -r \"$CONFIG\" || { echo \"config not readable: $CONFIG\" >&2; exit 1; }\nlinera-exporter run --config \"$CONFIG\"","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nlet config_path = Path::new(&options.config_path);\nlet meta = std::fs::metadata(config_path)\n    .map_err(|e| anyhow::anyhow!(\"cannot access config {}: {e}\", config_path.display()))?;\nif !meta.is_file() {\n    anyhow::bail!(\"config path is not a file: {}\", config_path.display());\n}","typeGuard":null,"tryCatchPattern":"// The panic happens in a third-party binary; guard at the orchestration layer:\nuse std::process::Command;\nlet status = Command::new(\"linera-exporter\")\n    .args([\"run\", \"--config\", config_path])\n    .status()?;\nif !status.success() {\n    // read the panic message from stderr; typically 'Unable to read the configuration file'\n}","preventionTips":["Use absolute config paths in systemd units, Docker entrypoints, and cron jobs.","Add a `test -r <config>` preflight check in wrapper scripts before launching the exporter.","Mount config files explicitly in containers and verify with a readiness step."],"tags":["linera-exporter","config","file-not-found","panic","rust"],"backgroundTag":"config-file-not-found","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}