{"record":{"id":"bcac12e9ad83e1c3","repo":"influxdata/influxdb","slug":"unknown-format-type-expected-one-of-pretty-csv-or-json","errorCode":null,"errorMessage":"Unknown format type: {}. Expected one of 'pretty', 'csv' or 'json'","messagePattern":"Unknown format type: (.+?)\\. Expected one of 'pretty', 'csv' or 'json'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/influxdb_iox_client/src/format.rs","lineNumber":18,"sourceCode":"//! Output formatting utilities for Arrow record batches\n\nuse std::{fmt::Display, str::FromStr};\n\nuse thiserror::Error;\n\nuse arrow::{\n    self, csv::WriterBuilder, error::ArrowError, json::ArrayWriter, record_batch::RecordBatch,\n};\n\n/// Output formatting for InfluxQL.\npub mod influxql;\n\n/// Error type for results formatting\n#[derive(Debug, Error)]\npub enum Error {\n    /// Unknown formatting type\n    #[error(\"Unknown format type: {}. Expected one of 'pretty', 'csv' or 'json'\", .0)]\n    Invalid(String),\n\n    /// Error pretty printing\n    #[error(\"Arrow pretty printing error: {}\", .0)]\n    PrettyArrow(ArrowError),\n\n    /// Error during CSV conversion\n    #[error(\"Arrow csv printing error: {}\", .0)]\n    CsvArrow(ArrowError),\n\n    /// Error during JSON conversion\n    #[error(\"Arrow json printing error: {}\", .0)]\n    JsonArrow(ArrowError),\n\n    /// Error converting CSV output to utf-8\n    #[error(\"Error converting CSV output to UTF-8: {}\", .0)]\n    CsvUtf8(std::string::FromUtf8Error),\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/format.rs#L1-L36","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the exact supported values: 'pretty', 'csv', or 'json'","Check the case: the comparison is exact, so normalize the input with to_lowercase() before passing it","List accepted formats in your CLI help / validation and reject unknown values early with a clear message","Check the client version's format module for the current set of supported formats if upgrading from an older release"],"exampleFix":"// before\nlet fmt = Format::try_new(\"Pretty\", ...)?; // Invalid(\"Pretty\")\n// after\nlet name = \"Pretty\".to_lowercase();\nif ![\"pretty\", \"csv\", \"json\"].contains(&name.as_str()) {\n    eprintln!(\"unsupported format {name}; expected pretty, csv or json\");\n    std::process::exit(2);\n}\nlet fmt = Format::try_new(&name, ...)?;","handlingStrategy":"validation","validationCode":"fn validate_format(name: &str) -> Result<(), String> {\n    match name.to_lowercase().as_str() {\n        \"pretty\" | \"csv\" | \"json\" => Ok(()),\n        other => Err(format!(\n            \"unknown format type: {other}. Expected one of 'pretty', 'csv' or 'json'\"\n        )),\n    }\n}","typeGuard":"fn is_valid_format(name: &str) -> bool {\n    matches!(name.to_lowercase().as_str(), \"pretty\" | \"csv\" | \"json\")\n}","tryCatchPattern":null,"preventionTips":["Normalize format strings with to_lowercase() before passing to the factory","Validate the --format flag at CLI argument parsing time with a clear error message","Keep CLI help text listing exactly the supported values: pretty, csv, json"],"tags":["cli","validation","formatting"],"backgroundTag":"invalid-enum-value","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}