influxdata/influxdb · error · Error

Unknown format type: . Expected one of 'pretty', 'csv' or…

Error message

Unknown format type: {}. Expected one of 'pretty', 'csv' or 'json'

What it means

Error::Invalid is raised by the format module's dispatcher when the caller requests an output format by name that the library does not recognize. The message lists the accepted values: 'pretty', 'csv' or 'json'. It is a user-input validation error on the format string, carrying the offending value.

Solutions

  1. Use one of the exact supported values: 'pretty', 'csv', or 'json'
  2. Check the case: the comparison is exact, so normalize the input with to_lowercase() before passing it
  3. List accepted formats in your CLI help / validation and reject unknown values early with a clear message
  4. Check the client version's format module for the current set of supported formats if upgrading from an older release

Example fix

// before
let fmt = Format::try_new("Pretty", ...)?; // Invalid("Pretty")
// after
let name = "Pretty".to_lowercase();
if !["pretty", "csv", "json"].contains(&name.as_str()) {
    eprintln!("unsupported format {name}; expected pretty, csv or json");
    std::process::exit(2);
}
let fmt = Format::try_new(&name, ...)?;
Defensive patterns

Strategy: validation

Validate before calling

fn validate_format(name: &str) -> Result<(), String> {
    match name.to_lowercase().as_str() {
        "pretty" | "csv" | "json" => Ok(()),
        other => Err(format!(
            "unknown format type: {other}. Expected one of 'pretty', 'csv' or 'json'"
        )),
    }
}

Type guard

fn is_valid_format(name: &str) -> bool {
    matches!(name.to_lowercase().as_str(), "pretty" | "csv" | "json")
}

Prevention

When it happens

Trigger: Passing an unrecognized string to the format factory (e.g., Format::try_new / get_format in core/influxdb_iox_client/src/format.rs) such as 'table', 'lineprotocol', 'CSV' (wrong case), or an empty string from a --format CLI flag.

Common situations: CLI users typing an unlisted format name or using different casing; scripts passing a config value that changed between client releases; assuming 'lp' or 'pretty-json' exist when only pretty/csv/json are supported.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at core/influxdb_iox_client/src/format.rs:18

//! Output formatting utilities for Arrow record batches

use std::{fmt::Display, str::FromStr};

use thiserror::Error;

use arrow::{
    self, csv::WriterBuilder, error::ArrowError, json::ArrayWriter, record_batch::RecordBatch,
};

/// Output formatting for InfluxQL.
pub mod influxql;

/// Error type for results formatting
#[derive(Debug, Error)]
pub enum Error {
    /// Unknown formatting type
    #[error("Unknown format type: {}. Expected one of 'pretty', 'csv' or 'json'", .0)]
    Invalid(String),

    /// Error pretty printing
    #[error("Arrow pretty printing error: {}", .0)]
    PrettyArrow(ArrowError),

    /// Error during CSV conversion
    #[error("Arrow csv printing error: {}", .0)]
    CsvArrow(ArrowError),

    /// Error during JSON conversion
    #[error("Arrow json printing error: {}", .0)]
    JsonArrow(ArrowError),

    /// Error converting CSV output to utf-8
    #[error("Error converting CSV output to UTF-8: {}", .0)]
    CsvUtf8(std::string::FromUtf8Error),

View on GitHub (pinned to 06200ef96b)