linera-io/linera-protocol · error

Invalid configuration file format

Error message

Invalid configuration file format

What it means

After reading the config, run parses it with `toml::from_str::<BlockExporterConfig>` and expects success (linera-exporter/src/main.rs:239). The panic fires on TOML syntax errors or when the document does not match BlockExporterConfig's schema: unknown required keys absent, wrong value types, or structural mismatches. The panic message embeds toml's detailed error including line/column, which names the offending key.

Source

Thrown at linera-exporter/src/main.rs:240

impl RunOptions {
    #[cfg(with_metrics)]
    fn enable_memory_profiling(&self) -> bool {
        #[cfg(feature = "jemalloc")]
        {
            self.enable_memory_profiling
        }
        #[cfg(not(feature = "jemalloc"))]
        {
            false
        }
    }

    fn run(&self) -> anyhow::Result<()> {
        let config_string = fs_err::read_to_string(&self.config_path)
            .expect("Unable to read the configuration file");
        let mut config: BlockExporterConfig =
            toml::from_str(&config_string).expect("Invalid configuration file format");

        let node_options = NodeOptions {
            send_timeout: self.send_timeout,
            recv_timeout: self.recv_timeout,
            retry_delay: self.retry_delay,
            max_retries: self.max_retries,
            max_backoff: self.max_backoff,
        };

        if let Some(port) = self.metrics_port {
            if IS_WITH_METRICS {
                tracing::info!("overriding metrics port to {}", port);
                config.metrics_port = port;
            } else {
                tracing::warn!(
                    "Metrics are not enabled in this build, ignoring metrics port configuration."
                );
            }

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Read the panic message: it contains the TOML error with line and column pinpointing the bad key.
  2. Validate the file with a TOML linter or `python -c 'import tomllib; tomllib.load(open("config.toml","rb"))'`.
  3. Diff against a known-good example config from the same linera-exporter version (see the repo's example/ or CLI docs).
  4. Regenerate the config for your current version rather than porting one across versions by hand.

Example fix

# before: metrics_port = "9091"  (string instead of int -> parse panic)

# after
metrics_port = 9091
[storage]
# ... keys matching BlockExporterConfig for this version
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate before spawning the exporter process:
let raw = std::fs::read_to_string(config_path)?;
let config: BlockExporterConfig = toml::from_str(&raw)
    .map_err(|e| anyhow::anyhow!("invalid exporter config: {e}"))?; // surfaced as an error, not a panic

Try / catch

let parsed = std::panic::catch_unwind(|| toml::from_str::<BlockExporterConfig>(&raw).expect("Invalid configuration file format"));
if parsed.is_err() {
    // print toml diagnostics path: run `python -m tomllib` or a TOML linter on the file
}

Prevention

When it happens

Trigger: Supplying a config whose TOML is malformed (unbalanced brackets, missing quotes) or whose keys/types diverge from BlockExporterConfig - e.g. a missing storage section, a wrong-typed metrics_port, or a config written for a different linera-exporter version.

Common situations: Hand-editing the exporter config and breaking syntax; upgrading linera-exporter to a version with a changed config schema while reusing the old file; copying an example config from a mismatched release; YAML-vs-TOML confusion.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/ba5ef01920ebee9f. Report an issue: GitHub.