{"record":{"id":"25ad49d795450a5b","repo":"zed-industries/zed","slug":"failed-to-open-output-file-for-rewriting","errorCode":null,"errorMessage":"Failed to open output file for rewriting","messagePattern":"Failed to open output file for rewriting","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/main.rs","lineNumber":1067,"sourceCode":"                    kept_lines.push(line);\n                }\n            }\n        }\n    }\n\n    let total = examples.len();\n    let already_processed = kept_hashes.len();\n\n    eprintln!(\n        \"Resuming: {}/{} examples already processed\",\n        already_processed, total\n    );\n\n    let file = OpenOptions::new()\n        .write(true)\n        .truncate(true)\n        .open(path)\n        .expect(\"Failed to open output file for rewriting\");\n    let mut writer = BufWriter::new(file);\n    for line in &kept_lines {\n        writeln!(writer, \"{}\", line).expect(\"Failed to write to output file\");\n    }\n    writer.flush().expect(\"Failed to flush output file\");\n\n    examples.retain(|e| !kept_hashes.contains(&spec_hash(&e.spec)));\n}\n\nfn main() {\n    let args = EpArgs::parse();\n\n    if args.printenv {\n        ::util::shell_env::print_env();\n        return;\n    }\n\n    let output = args.output_path();","sourceCodeStart":1049,"sourceCodeEnd":1085,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/main.rs#L1049-L1085","documentation":"Panics in the edit prediction CLI when reopening the JSONL output file with truncation for the resume pass fails (permissions, path moved, disk full). The tool rewrites the file with only unprocessed examples.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/main.rs:1067 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the output path is writable and the disk has space","Ensure no other process holds the output file open","Re-run from a directory with write permissions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}