openai/codex · error · GitToolingError

git command ` ` produced non-UTF-8 output

Error message

git command `{command}` produced non-UTF-8 output

What it means

GitToolingError::GitOutputUtf8: a git command completed but its stdout/stderr could not be decoded as UTF-8. The FromUtf8Error source identifies the bad bytes; worktree snapshot code requires textual git output, so binary/corrupt output is an error.

Solutions

  1. Add -z (NUL-terminated) or --encoding=UTF-8 flags to the git invocation so output is ASCII/UTF-8 safe
  2. Avoid operating on paths with non-UTF-8 bytes, or quote/escape them
  3. Treat the error as non-fatal and skip the affected entry if the tooling permits
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at codex-rs/git-utils/src/errors.rs:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/99d96ecdc6cad783. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/git-utils/src/errors.rs:17

use std::path::PathBuf;
use std::process::ExitStatus;
use std::string::FromUtf8Error;

use thiserror::Error;
use walkdir::Error as WalkdirError;

/// Errors returned while managing git worktree snapshots.
#[derive(Debug, Error)]
pub enum GitToolingError {
    #[error("git command `{command}` failed with status {status}: {stderr}")]
    GitCommand {
        command: String,
        status: ExitStatus,
        stderr: String,
    },
    #[error("git command `{command}` produced non-UTF-8 output")]
    GitOutputUtf8 {
        command: String,
        #[source]
        source: FromUtf8Error,
    },
    #[error("{path:?} is not a git repository")]
    NotAGitRepository { path: PathBuf },
    #[error("path {path:?} must be relative to the repository root")]
    NonRelativePath { path: PathBuf },
    #[error("path {path:?} escapes the repository root")]
    PathEscapesRepository { path: PathBuf },
    #[error("failed to process path inside worktree")]
    PathPrefix(#[from] std::path::StripPrefixError),
    #[error(transparent)]
    Walkdir(#[from] WalkdirError),
    #[error(transparent)]
    Io(#[from] std::io::Error),
}

View on GitHub (pinned to 339751715c)