wasmerio/wasmer · error

Invalid client config: unknown config version '{version}'

Error message

Invalid client config: unknown config version '{version}'

What it means

`EdgeConfig::from_slice` parses a client edge config (TOML) and first requires a `version` key whose integer value matches the struct's current VERSION constant. If the version differs — config written by an older or newer client, or hand-edited — parsing is refused so fields are never misinterpreted across incompatible schemas. This is an explicit schema-compatibility guard.

Source

Thrown at lib/cli/src/edge_config.rs:38

    /// Token used for network access.
    pub network_token: Option<String>,
}

impl EdgeConfig {
    pub const VERSION: u32 = 1;

    pub fn from_slice(data: &[u8]) -> Result<Self, anyhow::Error> {
        let data_str = std::str::from_utf8(data)?;
        let value: toml::Value = toml::from_str(data_str).context("failed to parse config TOML")?;

        let version = value
            .get("version")
            .and_then(|v| v.as_integer())
            .context("invalid client config: no 'version' key found")?;

        if version != Self::VERSION as i64 {
            bail!("Invalid client config: unknown config version '{version}'");
        }

        let config = toml::from_str(data_str)?;
        Ok(config)
    }

    /// Get a valid SSH token.
    ///
    /// Will filter out the stored token if it has expired.
    pub fn get_valid_ssh_token(&self, app_id: Option<&str>) -> Option<&str> {
        #[allow(clippy::manual_filter)]
        if let Some(app_id) = app_id {
            let token = self.ssh_app_tokens.get(app_id)?;
            if jwt_token_valid(token) {
                Some(token)
            } else {
                None
            }

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Regenerate the config with the installed CLI version (e.g. re-run `wasmer login` / the command that writes the edge config)
  2. Inspect the file and set `version = <N>` to the value expected by your CLI (check `EdgeConfig::VERSION` in lib/cli/src/edge_config.rs)
  3. Upgrade or downgrade the wasmer CLI to the version that wrote the config, then migrate
  4. Back up and delete the stale config file so the CLI recreates it

Example fix

// before (edge config)
version = 1

// after (matching EdgeConfig::VERSION = 2)
version = 2
Defensive patterns

Strategy: validation

Validate before calling

let raw = std::fs::read_to_string(path)?;
let v: toml::Value = raw.parse()?;
match v.get("version").and_then(|x| x.as_integer()) {
    Some(ver) if ver == EXPECTED_VERSION => {},
    Some(ver) => eprintln!("config version {ver} != expected {EXPECTED_VERSION}; regenerate config"),
    None => eprintln!("config missing 'version' key"),
}

Type guard

fn has_valid_version(v: &toml::Value, expected: i64) -> bool {
    v.get("version").and_then(|x| x.as_integer()) == Some(expected)
}

Try / catch

match EdgeConfig::from_slice(&data) {
    Ok(cfg) => cfg,
    Err(e) if e.to_string().contains("unknown config version") => {
        eprintln!("Config written by a different wasmer version — regenerate it");
        return Err(e);
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Loading an edge config file whose top-level `version` integer != Self::VERSION (e.g. a config generated by an older wasmer release), or a config missing the `version` key entirely (that path raises the related "no 'version' key found" context error).

Common situations: Upgrading or downgrading the wasmer CLI so the on-disk config format changed; manually editing ~/.wasmer edge config and altering/removing the version field; copying a config from a different deployment.

Related errors


AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01). Data as JSON: /api/errors/bc47690fc75be4f2. Report an issue: GitHub.