{"record":{"id":"adbae71dd92a947c","repo":"PRQL/prql","slug":"unknown-debug-log-format-for-file-path","errorCode":null,"errorMessage":"unknown debug log format for file {path:?}","messagePattern":"unknown debug log format for file (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/cli/mod.rs","lineNumber":596,"sourceCode":"pub fn write_log(path: &std::path::Path) -> Result<()> {\n    let debug_log = if let Some(debug_log) = debug::log_finish() {\n        debug_log\n    } else {\n        return Err(anyhow!(\n            \"debug log was started, but it cannot be found after compilation\"\n        ));\n    };\n    match path.extension().and_then(|s| s.to_str()) {\n        Some(\"json\") => {\n            let file = BufWriter::new(File::create(path)?);\n            serde_json::to_writer(file, &debug_log)?;\n        }\n        Some(\"html\") => {\n            let file = BufWriter::new(File::create(path)?);\n            debug::render_log_to_html(file, &debug_log)?;\n        }\n        _ => {\n            return Err(anyhow!(\"unknown debug log format for file {path:?}\"));\n        }\n    }\n    Ok(())\n}\n\nfn drop_module_def(stmts: &mut Vec<pr::Stmt>, name: &str) {\n    stmts.retain(|x| x.kind.as_module_def().is_none_or(|m| m.name != name));\n}\n\nfn read_files(input: &mut clio::ClioPath) -> Result<SourceTree> {\n    // Should this function move to a SourceTree constructor?\n    let root = input.path();\n\n    let mut sources = HashMap::new();\n    for file in input.clone().files(has_extension(\"prql\"))? {\n        let path = file.path().strip_prefix(root)?.to_owned();\n\n        let mut file_contents = String::new();","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/cli/mod.rs#L578-L614","documentation":"After compilation, `write_log` dispatches on the debug-log file extension: `json` and `html` are supported renderers; any other (or missing) extension hits this fallback error. It's a user-facing format validation error, not an internal bug.","triggerScenarios":"Passing a debug log path whose extension is neither `.json` nor `.html` (e.g. `--debug-log out.txt`, `log`, `log.yaml`).","commonSituations":"Typo in the output filename; assuming any extension works; shell completion absent so users guess the format.","solutions":["Use a `.json` extension for raw log output","Use an `.html` extension for a rendered trace view","Rename the target file to one of the supported extensions and rerun"],"exampleFix":"// before\nprqlc compile --debug-log trace.txt\n// after\nprqlc compile --debug-log trace.html","handlingStrategy":"validation","validationCode":"const valid = (p: string) => /\\.(json|html)$/i.test(p);","typeGuard":"function isDebugLogPath(p: string): p is `${string}.json` | `${string}.html` { return /\\.(json|html)$/i.test(p); }","tryCatchPattern":"try { writeLog(path) } catch (e) { if (String(e).includes('unknown debug log format')) { writeLog(path.replace(/\\.\\w+$/, '.json')) } else { throw e } }","preventionTips":["Always end debug-log filenames with .json or .html","Validate the path extension in wrapper scripts before invoking prqlc"],"tags":["cli","debug-logging","file-format","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}