{"record":{"id":"bfc9ff7d5c5d7f03","repo":"influxdata/influxdb","slug":"invalid-influxql-metadata-0","errorCode":null,"errorMessage":"Invalid InfluxQL metadata: {0}","messagePattern":"Invalid InfluxQL metadata: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/influxdb_iox_client/src/format/influxql.rs","lineNumber":24,"sourceCode":"use comfy_table::{Cell, Table};\nuse generated_types::influxdata::iox::querier::v1::InfluxQlMetadata;\nuse std::io::Write;\nuse std::iter;\nuse thiserror::Error;\n\n/// Error type for results formatting\n#[derive(Debug, Error)]\npub enum Error {\n    /// Arrow error.\n    #[error(\"Arrow error: {}\", .0)]\n    Arrow(ArrowError),\n\n    /// [`InfluxQlMetadata`] not found in Arrow schema metadata.\n    #[error(\"Missing InfluxQL metadata\")]\n    MissingMetadata,\n\n    /// Error deserializing [`InfluxQlMetadata`] from Arrow schema metadata.\n    #[error(\"Invalid InfluxQL metadata: {0}\")]\n    InvalidMetadata(#[from] serde_json::Error),\n\n    /// Error writing formatted output.\n    #[error(\"Error writing output: {0}\")]\n    Write(#[from] std::io::Error),\n}\ntype Result<T, E = Error> = std::result::Result<T, E>;\n\n/// Options for controlling how table borders are rendered.\n#[derive(Debug, Default, Clone, Copy)]\npub enum TableBorders {\n    /// Use ASCII characters.\n    #[default]\n    Ascii,\n    /// Use UNICODE box-drawing characters.\n    Unicode,\n    /// Do not render borders.\n    None,","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/format/influxql.rs#L6-L42","documentation":"Error::InvalidMetadata wraps a serde_json::Error produced when deserializing InfluxQlMetadata from the Arrow schema metadata map. The metadata key exists but its JSON payload cannot be parsed into the expected struct (via #[from] serde_json::Error), so the formatter reports 'Invalid InfluxQL metadata: {0}'.","triggerScenarios":"Formatting batches whose schema metadata contains an InfluxQlMetadata value that is not valid JSON or does not match the InfluxQlMetadata struct fields — e.g., payload produced by an incompatible server version or manually written test metadata.","commonSituations":"Client and server version skew (metadata JSON schema changed between IOx releases); hand-crafting the metadata entry with wrong field names/types; metadata string corrupted by an intermediary proxy rewriting headers/annotations.","solutions":["Log the raw metadata string and the inner serde_json error to see which field/shape mismatched","Align client and server versions so InfluxQlMetadata serialization matches on both sides","Fix the metadata JSON in test fixtures to match the InfluxQlMetadata struct (correct field names and types)","Catch this variant and fall back to a plain formatter (csv/json) if you only need raw rows, not line protocol"],"exampleFix":"// before\n// metadata: {\"measurement\": \"cpu\"} // missing required fields\nlet out = formatter.format(&batches)?;\n// after\n// metadata: {\"measurement\": \"cpu\", \"tag_keys\": [\"host\"], \"field_keys\": [\"usage\"]}\nlet out = formatter.format(&batches)?;","handlingStrategy":"try-catch","validationCode":"fn metadata_is_valid_json(batches: &[RecordBatch], key: &str) -> bool {\n    batches.first()\n        .and_then(|b| b.schema().metadata().get(key))\n        .map(|v| serde_json::from_str::<serde_json::Value>(v).is_ok())\n        .unwrap_or(false)\n}","typeGuard":"fn is_invalid_metadata(e: &influxql_format::Error) -> bool {\n    matches!(e, influxql_format::Error::InvalidMetadata(_))\n}","tryCatchPattern":"match formatter.format(&batches) {\n    Err(influxql_format::Error::InvalidMetadata(src)) => {\n        eprintln!(\"metadata JSON parse failed: {src}; falling back to csv\");\n        csv_formatter.format(&batches)?;\n    }\n    other => other?,\n}","preventionTips":["Fix test fixture metadata to match InfluxQlMetadata field names/types exactly","Pin matching client/server versions to avoid metadata schema drift","Log the raw metadata payload when deserialization fails"],"tags":["arrow","metadata","serialization","influxql"],"backgroundTag":"json-unmarshal-failed","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"}