{"record":{"id":"a7665f6e5e1da28d","repo":"zed-industries/zed","slug":"failed-to-write-to-failed-jsonl","errorCode":null,"errorMessage":"Failed to write to failed.jsonl","messagePattern":"Failed to write to failed\\.jsonl","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/main.rs","lineNumber":1664,"sourceCode":"                &serde_json::to_vec_pretty(&example).unwrap(),\n            )\n            .await\n            .unwrap();\n        let err_path = FAILED_EXAMPLES_DIR.join(format!(\"{}_err.txt\", example_name));\n        app_state\n            .fs\n            .write(&err_path, format!(\"{error:?}\").as_bytes())\n            .await\n            .unwrap();\n\n        let failed_jsonl_path = RUN_DIR.join(\"failed.jsonl\");\n        let mut file = OpenOptions::new()\n            .create(true)\n            .append(true)\n            .open(&failed_jsonl_path)\n            .expect(\"Failed to open failed.jsonl\");\n        writeln!(file, \"{}\", serde_json::to_string(example).unwrap())\n            .expect(\"Failed to write to failed.jsonl\");\n\n        let cursor_path = match example.repo_name() {\n            Ok(repo_name) => repo_name.worktree_path().join(&example.spec.cursor_path),\n            Err(_) => example.spec.cursor_path.as_ref().to_path_buf(),\n        };\n        msg = format!(\n            indoc::indoc! {\"\n                While processing \\\"{}\\\":\n\n                \\x1b[31m{:?}\\x1b[0m\n\n                Example:        \\x1b[36m{}\\x1b[0m\n                Error file:     \\x1b[36m{}\\x1b[0m\n                Cursor file:    \\x1b[36m{}\\x1b[0m\n                Re-run:         cargo run -p edit_prediction_cli -- {} \\x1b[36m{}\\x1b[0m\n            \"},\n            example.spec.name,\n            error,","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/main.rs#L1646-L1682","documentation":"Panics when OpenOptions::open fails to open failed.jsonl in the run directory for appending. The .expect fires on any io::Error from open: the RUN_DIR timestamped directory does not exist yet, the path is read-only, disk quota is exhausted, or another process holds an incompatible lock. It fires before any write happens, so the failure is about opening the log file, not writing records to it.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/main.rs:1664 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace .expect with ? and propagate the io::Error with .context(\"Failed to open failed.jsonl\") so the caller's anyhow handler reports it","Create the run directory with create_dir_all before opening the log file","Fall back to writing the failed example to stderr if the jsonl file cannot be opened, so the failure record is never silently lost"],"exampleFix":null,"handlingStrategy":"try-catch","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"}