{"record":{"id":"d4544f9650bcc14d","repo":"GitoxideLabs/gitoxide","slug":"no-illformed-utf-8","errorCode":null,"errorMessage":"no illformed UTF-8","messagePattern":"no illformed UTF-8","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix/src/worktree/mod.rs","lineNumber":110,"sourceCode":"    /// Return the ID of the repository worktree, if it is a linked worktree, or `None` if it's a linked worktree.\n    pub fn id(&self) -> Option<&BStr> {\n        id(self.parent.git_dir(), self.parent.common_dir.is_some())\n    }\n\n    /// Returns true if the `.git` file or directory exists within the worktree.\n    ///\n    /// This is an indicator for the worktree to be checked out particularly if the parent repository is a submodule.\n    pub fn dot_git_exists(&self) -> bool {\n        self.path.join(gix_discover::DOT_GIT_DIR).exists()\n    }\n}\n\npub(crate) fn id(git_dir: &std::path::Path, has_common_dir: bool) -> Option<&BStr> {\n    if !has_common_dir {\n        return None;\n    }\n    let candidate = gix_path::os_str_into_bstr(git_dir.file_name().expect(\"at least one directory level\"))\n        .expect(\"no illformed UTF-8\");\n    let maybe_worktrees = git_dir.parent()?;\n    (maybe_worktrees.file_name()?.to_str()? == \"worktrees\").then_some(candidate)\n}\n\n///\npub mod proxy;\n\n///\n#[cfg(feature = \"index\")]\npub mod open_index {\n    /// The error returned by [`Worktree::open_index()`][crate::Worktree::open_index()].\n    #[derive(Debug, thiserror::Error)]\n    #[expect(missing_docs)]\n    pub enum Error {\n        #[error(transparent)]\n        ConfigIndexThreads(#[from] crate::config::key::GenericErrorWithValue),\n        #[error(transparent)]\n        ConfigSkipHash(#[from] crate::config::boolean::Error),","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix/src/worktree/mod.rs#L92-L128","documentation":"Same function as error 534: after extracting the file name, the helper converts the `OsStr` to a `BStr` with `gix_path::os_str_into_bstr(...).expect(\"no illformed UTF-8\")`. The conversion only fails on non-Unicode-convertible OS strings, so the expect asserts the worktree directory name is valid. A worktree directory containing unencodable bytes on Unix (e.g. invalid UTF-8 in the name) triggers the panic.","triggerScenarios":"A linked worktree whose directory name under `.git/worktrees/` contains bytes that are not valid UTF-8 (possible on Linux filesystems), then accessing worktree APIs that call this helper.","commonSituations":"Worktree names created by scripts with raw bytes, locale-dependent names, or files created with non-UTF-8 encodings; mostly Linux/Unix.","solutions":["Rename the worktree directory (and update `.git/worktrees` metadata, e.g. via `git worktree` commands) to use valid UTF-8.","Avoid creating worktrees whose names come from untrusted byte sources; validate names are UTF-8 first.","Report to gitoxide if stricter non-panicking conversion is preferred."],"exampleFix":"// before\nlet name = std::str::from_utf8(os_bytes).unwrap();\n// after (caller-side validation)\nlet name = std::str::from_utf8(os_bytes)\n    .expect(\"worktree name must be valid UTF-8\"); // validated before creating the worktree","handlingStrategy":"validation","validationCode":"let name = git_dir.file_name().and_then(|n| n.to_str());\nif name.is_none() { return Err(anyhow::anyhow!(\"worktree dir name is not UTF-8\")); }\n","typeGuard":"fn valid_utf8_name(p: &std::path::Path) -> bool { p.file_name().map_or(false, |n| n.to_str().is_some()) }\n","tryCatchPattern":null,"preventionTips":["Create worktree directories with valid UTF-8 names only","Avoid deriving worktree names from raw bytes or user input without validation","Use git worktree CLI rather than hand-crafted directories"],"tags":["panic","encoding","utf-8","worktree","git"],"backgroundTag":"invalid-argument-format","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}