{"record":{"id":"ffa0fa97d43afe5d","repo":"gitbutlerapp/gitbutler","slug":"write-to-memory-succeeds","errorCode":null,"errorMessage":"write to memory succeeds","messagePattern":"write to memory succeeds","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/gitbutler-oplog/src/reflog.rs","lineNumber":152,"sourceCode":"            new_oid: new_oid_string.as_str().into(),\n            signature,\n            message: message.as_str().into(),\n        };\n\n        previous_oid = *commit_id;\n\n        log.push_str(&serialize_line(reflog_line));\n        log.push('\\n');\n    }\n\n    log\n}\n\nfn serialize_line(line: gix::refs::file::log::LineRef<'_>) -> String {\n    let mut sig = Vec::new();\n    line.signature\n        .write_to(&mut sig)\n        .expect(\"write to memory succeeds\");\n\n    format!(\n        \"{} {} {}\\t{}\",\n        line.previous_oid,\n        line.new_oid,\n        std::str::from_utf8(&sig).expect(\"no illformed UTF8\"),\n        line.message\n    )\n}\n\n#[cfg(test)]\nmod set_target_ref {\n    use std::str::FromStr;\n\n    use but_testsupport::{CommandExt, git_at_dir};\n    use gix::refs::file::log::LineRef;\n    use pretty_assertions::assert_eq;\n    use tempfile::tempdir;","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/gitbutler-oplog/src/reflog.rs#L134-L170","documentation":"serialize_line() in gitbutler-oplog formats one parsed reflog line and writes the gix signature into an in-memory Vec<u8> with write_to(...).expect(\"write to memory succeeds\"). Writing into a Vec has no file descriptor and cannot fail with io::Error, so this expect is an infallibility annotation, not a runtime check - it documents why the Result is deliberately discarded.","triggerScenarios":"Any execution of the oplog reflog-serialization path (building reflog strings when snapshots/undo data is recorded). The panic arm is effectively unreachable; only a custom writer implementation that starts erroring could trip it.","commonSituations":"None user-visible. This is a code-reading/contribution context: reviewers may wonder why the io::Result is ignored, and the expect answers that.","solutions":["No action needed for users of the library","Contributors: keep it as-is, or express infallibility explicitly (see exampleFix)","Do not 'fix' this by adding real I/O here without also switching the function to error propagation"],"exampleFix":"// before\nline.signature.write_to(&mut sig).expect(\"write to memory succeeds\");\n\n// after - make infallibility explicit instead of message-based\nline.signature.write_to(&mut sig).unwrap_or_else(|err| match err {});","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat this panic as a code defect, not an environment issue - it cannot fire from user input","Do not replace the in-memory Vec writer with file I/O without adding error propagation","Keep serialization unit tests (the file has a set_target_ref test module) exercising this path"],"tags":["rust","invariant","reflog","io","oplog","panic"],"backgroundTag":"unreachable-invariant-panic","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}