gitbutlerapp/gitbutler · error

Unknown

Unknown

Error message

git fetch worker thread panicked: {reason}

What it means

Wraps a panic caught from the dedicated git fetch worker thread. fetch runs git fetch on a spawned thread; a catch_unwind converts any panic payload into this anyhow error with code Unknown, since the fetch never produced a normal result.

Solutions

  1. Read the inner panic reason in the error chain to find the panicking assertion.
  2. Check repo integrity (`git fsck`) and retry.
  3. Run `git fetch <remote>` manually to see if plain git also fails.
  4. Report as a bug with the panic reason if the underlying CLI fetch succeeds.
Defensive patterns

Strategy: try-catch

Validate before calling

std::process::Command::new("git").args(["fetch", remote]).status()?; // sanity-check repo handles fetch

Try / catch

match ctx.fetch(remote, None) {
    Err(e) if e.to_string().contains("worker thread panicked") => {
        log::error!("fetch panicked: {e:#}"); // inspect chained reason, run git fsck
    }
    r => r?,
}

Prevention

When it happens

Trigger: The fetch worker thread panics — e.g. invalid UTF-8 in unexpected output, an internal assertion/ref parse failure, or a bug in fetch plumbing triggered by an unusual repo state or malformed remote output.

Common situations: Repos with exotic ref names or malformed packed-refs entries; corrupted .git directory; git hook or remote output that trips an unwrap inside the worker; version-specific gix bugs.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/7a6e2b2dc4772a98. Report an issue: GitHub.

Appendix: source

Thrown at crates/gitbutler-git/src/context.rs:180

        )?;
        Ok(runtime.block_on(crate::fetch(
            repo_path,
            crate::tokio::TokioExecutor,
            &remote,
            on_prompt,
        )))
    })
    .join()
    .map_err(|panic| {
        let reason = if let Some(message) = panic.downcast_ref::<String>() {
            message.clone()
        } else if let Some(message) = panic.downcast_ref::<&'static str>() {
            (*message).to_owned()
        } else {
            "unknown panic payload".to_owned()
        };

        anyhow!("git fetch worker thread panicked: {reason}").context(
            but_error::Context::new("git fetch failed unexpectedly").with_code(Code::Unknown),
        )
    })??;
    result.map_err(map_needs_authorization)
}

/// The concrete error type produced by fetch/push through the tokio executor.
type GitError = crate::Error<crate::repository::Error<crate::tokio::TokioExecutor>>;

/// Convert the error into an anyhow error, giving `NeedsAuthorization` failures a message that
/// tells the user what to do about it (see [`needs_authorization_message`]); every other error
/// converts as-is.
fn map_needs_authorization(err: GitError) -> anyhow::Error {
    let crate::Error::Backend(crate::repository::RepositoryError::NeedsAuthorization(ref prompt)) =
        err
    else {
        return err.into();
    };

View on GitHub (pinned to 58e5313667)