can1357/oh-my-pi · error · Error

{context}: {message}

Error message

{context}: {message}

What it means

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.

Source

Thrown at crates/pi-vcs/src/error.rs:88

		/// Captured stdout (may be truncated).
		stdout:    String,
		/// Captured stderr (may be truncated).
		stderr:    String,
	},

	/// A CLI-backed operation exceeded its deadline and was killed.
	#[error("timed out: {command}")]
	CliTimeout {
		/// Rendered command line.
		command: String,
	},

	/// Filesystem error outside any more specific failure mode.
	#[error(transparent)]
	Io(#[from] std::io::Error),

	/// An underlying gix / jj-lib failure that has no dedicated variant.
	#[error("{context}: {message}")]
	Backend {
		/// Operation being performed (`"git status"`, `"jj snapshot"`, …).
		context: &'static str,
		/// Backend error rendered as text (full source chain).
		message: String,
	},

	/// The operation was canceled via its interrupt flag.
	#[error("operation canceled")]
	Canceled,
	/// The operation has no implementation on this backend (e.g. staged diffs
	/// on a Jujutsu workspace, which has no index).
	#[error(
		"`{operation}` is not supported on a {} repository",
		match backend {
			crate::VcsKind::Git => "git",
			crate::VcsKind::Jj => "jj",
		}

View on GitHub (pinned to 9690622007)

Solutions

  1. Read `message` (full source chain) to identify the root cause — it usually names the underlying gix/jj issue.
  2. For lock contention/corruption: remove stale `*.lock` files under .git only after confirming no git process is running.
  3. Run `git fsck` (or `jj util gc` for jj) to detect and repair repository corruption.
  4. Check file permissions on .git and free disk space if the chain mentions EACCES/ENOSPC.

Example fix

// before
let st = repo.status()?; // Backend { context: "git status", message: "..." } — opaque
// after
match repo.status() {
    Err(Error::Backend { context, message }) => {
        logger.error("vcs backend failed", ctx: context, err: message);
        if message.contains("index.lock") { fs::remove_file(".git/index.lock")?; retry(status); }
        else { return Err(anyhow!("{context}: {message}")); }
    }
    other => other.map_err(Into::into),
}
Defensive patterns

Strategy: try-catch

Validate before calling

fn repo_healthy(dir: &Path) -> bool {
    std::process::Command::new("git").args(["fsck", "--no-progress"]).current_dir(dir)
        .status().map(|s| s.success()).unwrap_or(false)
}
if !repo_healthy(&workdir) { eprintln!("repository corruption suspected — run git fsck"); }

Type guard

fn is_backend_error(err: &pi_vcs::Error) -> Option<(&'static str, &str)> {
    match err {
        pi_vcs::Error::Backend { context, message } => Some((context, message)),
        _ => None,
    }
}

Try / catch

match repo.status() {
    Err(pi_vcs::Error::Backend { context, message }) => {
        if message.contains("index.lock") {
            let _ = fs::remove_file(workdir.join(".git/index.lock"));
            retry(status);
        } else {
            anyhow::bail!("{context} failed: {message}");
        }
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/07fc1f2dfa9579d3. Report an issue: GitHub.