{"record":{"id":"07fc1f2dfa9579d3","repo":"can1357/oh-my-pi","slug":"context-message","errorCode":null,"errorMessage":"{context}: {message}","messagePattern":"\\{context\\}: \\{message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pi-vcs/src/error.rs","lineNumber":88,"sourceCode":"\t\t/// Captured stdout (may be truncated).\n\t\tstdout:    String,\n\t\t/// Captured stderr (may be truncated).\n\t\tstderr:    String,\n\t},\n\n\t/// A CLI-backed operation exceeded its deadline and was killed.\n\t#[error(\"timed out: {command}\")]\n\tCliTimeout {\n\t\t/// Rendered command line.\n\t\tcommand: String,\n\t},\n\n\t/// Filesystem error outside any more specific failure mode.\n\t#[error(transparent)]\n\tIo(#[from] std::io::Error),\n\n\t/// An underlying gix / jj-lib failure that has no dedicated variant.\n\t#[error(\"{context}: {message}\")]\n\tBackend {\n\t\t/// Operation being performed (`\"git status\"`, `\"jj snapshot\"`, …).\n\t\tcontext: &'static str,\n\t\t/// Backend error rendered as text (full source chain).\n\t\tmessage: String,\n\t},\n\n\t/// The operation was canceled via its interrupt flag.\n\t#[error(\"operation canceled\")]\n\tCanceled,\n\t/// The operation has no implementation on this backend (e.g. staged diffs\n\t/// on a Jujutsu workspace, which has no index).\n\t#[error(\n\t\t\"`{operation}` is not supported on a {} repository\",\n\t\tmatch backend {\n\t\t\tcrate::VcsKind::Git => \"git\",\n\t\t\tcrate::VcsKind::Jj => \"jj\",\n\t\t}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-vcs/src/error.rs#L70-L106","documentation":"Error::Backend wraps an underlying gix or jj-lib failure that has no dedicated variant in this error enum. It pairs a static operation context (e.g. \"git status\", \"jj snapshot\") with the backend error rendered as text including its full source chain, so nothing is lost while keeping the public error type small.","triggerScenarios":"Any library-internal call into gix/jj-lib that errors outside the enumerated cases: object database corruption, packfile/index read failures, worktree traversal errors, lock-file contention, or jj snapshot conflicts during auto-snapshot.","commonSituations":"Corrupted .git directory (interrupted gc, disk-full during write), stale index.lock files after a crashed process, permission problems on .git internals, unsupported repository features for the backend version, or concurrent processes mutating the repo mid-operation.","solutions":["Read `message` (full source chain) to identify the root cause — it usually names the underlying gix/jj issue.","For lock contention/corruption: remove stale `*.lock` files under .git only after confirming no git process is running.","Run `git fsck` (or `jj util gc` for jj) to detect and repair repository corruption.","Check file permissions on .git and free disk space if the chain mentions EACCES/ENOSPC."],"exampleFix":"// before\nlet st = repo.status()?; // Backend { context: \"git status\", message: \"...\" } — opaque\n// after\nmatch repo.status() {\n    Err(Error::Backend { context, message }) => {\n        logger.error(\"vcs backend failed\", ctx: context, err: message);\n        if message.contains(\"index.lock\") { fs::remove_file(\".git/index.lock\")?; retry(status); }\n        else { return Err(anyhow!(\"{context}: {message}\")); }\n    }\n    other => other.map_err(Into::into),\n}","handlingStrategy":"try-catch","validationCode":"fn repo_healthy(dir: &Path) -> bool {\n    std::process::Command::new(\"git\").args([\"fsck\", \"--no-progress\"]).current_dir(dir)\n        .status().map(|s| s.success()).unwrap_or(false)\n}\nif !repo_healthy(&workdir) { eprintln!(\"repository corruption suspected — run git fsck\"); }","typeGuard":"fn is_backend_error(err: &pi_vcs::Error) -> Option<(&'static str, &str)> {\n    match err {\n        pi_vcs::Error::Backend { context, message } => Some((context, message)),\n        _ => None,\n    }\n}","tryCatchPattern":"match repo.status() {\n    Err(pi_vcs::Error::Backend { context, message }) => {\n        if message.contains(\"index.lock\") {\n            let _ = fs::remove_file(workdir.join(\".git/index.lock\"));\n            retry(status);\n        } else {\n            anyhow::bail!(\"{context} failed: {message}\");\n        }\n    }\n    other => other?,\n}","preventionTips":["Log the full `message` (source chain) — it identifies the true root cause in gix/jj-lib.","Avoid running multiple mutating git processes concurrently on the same repo.","Monitor disk space and clean up stale `.lock` files after crashes.","Run `git fsck` periodically in CI on long-lived working copies."],"tags":["vcs","git","backend","gix","jujutsu"],"backgroundTag":"vcs-backend-error","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}