influxdata/influxdb · error · anyhow::Error

must be formatted as "key=value"

Error message

must be formatted as "key=value"

What it means

Raised by FromStr::from_str for a key=value tuple type (e.g. a tag or field specification parsed from a CLI argument). The input string did not contain the SEPARATOR ('='), so split_once fails and this anyhow error is returned. The whole argument is rejected before key/value parsing is even attempted.

Solutions

  1. Re-run the command with each tag/field argument formatted as key=value, e.g. --tag host=server01.
  2. Check shell quoting so the '=' is passed through intact (quote the whole argument if it contains spaces).
  3. Inspect scripted/env-driven invocations for empty variables producing bare keys.
  4. Wrap key/value pairs containing '=' in the value (allowed; only the first '=' splits).

Example fix

// before
influxdb3 write --database mydb --tag host --tag-location us
// after
influxdb3 write --database mydb --tag host=server01 --tag-location=us
Defensive patterns

Strategy: validation

Validate before calling

fn validate_kv(arg: &str) -> Result<(), String> {
    if arg.split_once('=').is_none() {
        return Err(format!("argument '{arg}' must be formatted as key=value"));
    }
    Ok(())
}
// run validate_kv(tag_arg)? before invoking the CLI/library

Type guard

fn looks_like_key_value(s: &str) -> bool { s.contains('=') && !s.starts_with('=') }

Prevention

When it happens

Trigger: Passing a --tag or --field style CLI argument without an '=' separator, e.g. `--tag host` instead of `--tag host=server01`, or passing an empty/whitespace-only value to such an option.

Common situations: Typos when writing line-protocol-like arguments on the command line; shell quoting stripping the '=' is rare but possible; forgetting that multiple '=' are allowed in the value but at least one is required; scripted invocations building args from env vars that are empty.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/7c02d943ca54a59e. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_commands/src/common.rs:76

// A clap argument provided as a key/value pair separated by `SEPARATOR`, which by default is a '='
#[derive(Debug, Clone)]
pub struct SeparatedKeyValue<K, V, const SEPARATOR: char = '='>(pub (K, V));

impl<K, V, const SEPARATOR: char> FromStr for SeparatedKeyValue<K, V, SEPARATOR>
where
    K: FromStr<Err: Into<anyhow::Error>>,
    V: FromStr<Err: Into<anyhow::Error>>,
{
    type Err = anyhow::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let (key, value) = s
            // we only split once because the structure of our input is a SEPARATOR-separated tuple
            // and we need to allow the SEPARATOR value to be included multiple times in value side
            // of the tuple
            .split_once(SEPARATOR)
            .ok_or_else(|| anyhow::anyhow!("must be formatted as \"key=value\""))?;

        Ok(Self((
            key.parse().map_err(Into::into)?,
            value.parse().map_err(Into::into)?,
        )))
    }
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DataType {
    Int64,
    Uint64,
    Float64,
    Utf8,
    Bool,
}

#[derive(Debug, PartialEq, Eq, thiserror::Error)]

View on GitHub (pinned to 06200ef96b)