{"record":{"id":"2f9c9269eb3c1fc5","repo":"cloudflare/quiche","slug":"error-creating-file-for-url-attempted-path-was","errorCode":null,"errorMessage":"Error creating file for {url}, attempted path was {path}: {e}","messagePattern":"Error creating file for (.+?), attempted path was (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/src/common.rs","lineNumber":128,"sourceCode":"/// any value \"N\" greater than 1, will cause \".N\" to be appended to the\n/// filename.\nfn make_resource_writer(\n    url: &url::Url, target_path: &Option<String>, cardinal: u64,\n) -> Option<std::io::BufWriter<std::fs::File>> {\n    if let Some(tp) = target_path {\n        let resource =\n            url.path_segments().map(|c| c.collect::<Vec<_>>()).unwrap();\n\n        let mut path = format!(\"{}/{}\", tp, resource.iter().last().unwrap());\n\n        if cardinal > 1 {\n            path = format!(\"{path}.{cardinal}\");\n        }\n\n        match std::fs::File::create(&path) {\n            Ok(f) => return Some(std::io::BufWriter::new(f)),\n\n            Err(e) => panic!(\n                \"Error creating file for {url}, attempted path was {path}: {e}\"\n            ),\n        }\n    }\n\n    None\n}\n\nfn autoindex(path: path::PathBuf, index: &str) -> path::PathBuf {\n    if let Some(path_str) = path.to_str() {\n        if path_str.ends_with('/') {\n            let path_str = format!(\"{path_str}{index}\");\n            return path::PathBuf::from(&path_str);\n        }\n    }\n\n    path\n}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/cloudflare/quiche/blob/9f96daa2c22a4468b0036fb0a0a3894eee6498b8/apps/src/common.rs#L110-L146","documentation":"make_resource_writer panics when std::fs::File::create fails for the file that will store the response body of a downloaded URL. The panic includes the URL, the attempted path, and the underlying io::Error. Failure is typically due to filesystem permissions, a missing parent directory, or the path being a directory.","triggerScenarios":"Running quiche-client with a dump/save option where the derived output path (including the '.N' dedup suffix) cannot be created: parent directory missing, read-only filesystem, or permission denied.","commonSituations":"Saving responses into a directory that doesn't exist or isn't writable; running in a container with a read-only volume; disk full.","solutions":["Create the target directory first (mkdir -p) and verify write permissions.","Check the 'attempted path was' message for a wrong or malformed path.","Verify the filesystem is not read-only or full.","Prefer running the client from a directory you own if relative paths are used."],"exampleFix":"// before (directory does not exist)\nquiche-client --dump-dir /out https://example.org\n// after\nmkdir -p /out && quiche-client --dump-dir /out https://example.org","handlingStrategy":"validation","validationCode":"let dir = std::path::Path::new(&out_dir);\nassert!(dir.is_dir(), \"output dir missing: {}\", out_dir);\nassert!(!dir.is_file(), \"output path is a file: {}\");\nlet probe = dir.join(\".write_test\");\nstd::fs::File::create(&probe).expect(\"output dir not writable\");\nlet _ = std::fs::remove_file(&probe);","typeGuard":null,"tryCatchPattern":"// Since the app panics, isolate it: run in a subprocess and inspect stderr\nlet out = std::process::Command::new(\"quiche-client\")\n    .args([\"--dump-dir\", &out_dir, url])\n    .output()\n    .expect(\"spawn failed\");\nif !out.status.success() {\n    eprintln!(\"client failed: {}\", String::from_utf8_lossy(&out.stderr));\n}","preventionTips":["Always create the dump directory before running the client.","Run with write permissions on the target volume; avoid read-only containers.","Monitor free disk space for large downloads."],"tags":["filesystem","io","file-create"],"backgroundTag":"file-write-failed","analyzedSha":"9f96daa2c22a4468b0036fb0a0a3894eee6498b8","analyzedAt":"2026-09-08T11:27:09.536Z","contentChangedAt":"2026-09-08T11:27:09.536Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}