{"record":{"id":"513f79010a10493c","repo":"influxdata/influxdb","slug":"io-error-0-query","errorCode":null,"errorMessage":"io error: {0}","messagePattern":"io error: (.+?)","errorType":"error_code","errorClass":"Error::Io","httpStatus":null,"severity":"error","filePath":"influxdb3_commands/src/query.rs","lineNumber":25,"sourceCode":"use tokio::{\n    fs::OpenOptions,\n    io::{self, AsyncWriteExt},\n};\nuse url::Url;\n\nuse crate::common::Format;\n\nuse super::common::InfluxDb3Config;\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(transparent)]\n    Client(#[from] influxdb3_client::Error),\n\n    #[error(\"invlid UTF8 received from server: {0}\")]\n    Utf8(#[from] Utf8Error),\n\n    #[error(\"io error: {0}\")]\n    Io(#[from] io::Error),\n\n    #[error(\"cannot write parquet to a terminal, use `--output <file>` or pipe the output\")]\n    NoOutputFileForParquet,\n    #[error(\n        \"No input from stdin detected, no string was passed in,  and no file \\\n        path was given\"\n    )]\n    NoInput,\n}\n\npub type Result<T> = std::result::Result<T, Error>;\n\n#[derive(Debug, Parser)]\n#[clap(visible_alias = \"q\")]\npub struct Config {\n    /// Common InfluxDB 3 server config\n    #[clap(flatten)]","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_commands/src/query.rs#L7-L43","documentation":"The Io variant of influxdb3_commands::query::Error, converted via #[from] from std::io::Error. It wraps I/O failures in the query command, most notably failures writing the query output (parquet file creation/write, stdout pipe) or reading input files/stdin. The underlying std::io::Error is preserved as the source.","triggerScenarios":"Running `influxdb3 query --output file.parquet` where the file cannot be created or written (bad path, missing directory, permissions, disk full); reading query input from a file/stdin that fails; broken pipe when stdout is closed by the consumer (e.g. piping into `head`).","commonSituations":"--output path in a non-existent or read-only directory; disk quota exceeded while writing large parquet results; piping output to a short-lived consumer that exits early (broken pipe); insufficient permissions under restricted users/containers; stdin redirection mistakes.","solutions":["Check the error source (std::io::Error kind) to identify the exact I/O failure.","Verify the --output directory exists and is writable, or create it first.","Ensure sufficient disk space/quota for the parquet output size.","Fix pipe consumers (e.g. use `head -c` tolerant patterns) or redirect to a file instead; check file/stdin permissions.","Run with appropriate user permissions or adjust container volume mounts."],"exampleFix":"// before\ninfluxdb3 query --output /nonexistent-dir/results.parquet \"SELECT * FROM cpu\"\n// after\nmkdir -p ./results && influxdb3 query --output ./results/results.parquet \"SELECT * FROM cpu\"","handlingStrategy":"try-catch","validationCode":"// before requesting parquet output, ensure the destination is writable\nfn ensure_output_writable(path: &std::path::Path) -> std::io::Result<()> {\n    if let Some(dir) = path.parent() { std::fs::create_dir_all(dir)?; }\n    let f = std::fs::OpenOptions::new().create(true).append(true).open(path)?;\n    Ok(())\n}","typeGuard":"fn is_io_error(e: &influxdb3_commands::query::Error) -> bool {\n    matches!(e, influxdb3_commands::query::Error::Io(_))\n}","tryCatchPattern":"match run_query_with_output(path).await {\n    Err(influxdb3_commands::query::Error::Io(io)) if io.kind() == std::io::ErrorKind::BrokenPipe => {\n        // downstream consumer closed stdout; degrade gracefully\n    }\n    Err(e) => return Err(e.into()),\n    Ok(v) => v,\n}","preventionTips":["Pre-create the output directory and check disk space before large parquet exports.","Avoid piping output to consumers that exit early (e.g. `head`) or handle broken pipes.","Run the CLI with a user that has write permissions on the output path.","Check std::io::ErrorKind on the source to branch on permission vs space vs pipe issues.","Use `--output` to a file rather than a terminal for parquet results."],"tags":["io","filesystem","cli","rust"],"backgroundTag":"file-write-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"}