{"record":{"id":"37ca782f83c0f4d4","repo":"GitoxideLabs/gitoxide","slug":"no-illformed-utf-8-37ca78","errorCode":null,"errorMessage":"no illformed UTF-8","messagePattern":"no illformed UTF-8","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix/src/worktree/proxy.rs","lineNumber":70,"sourceCode":"            )\n        })?\n    }\n\n    /// Read the location of the checkout, the base of the work tree.\n    /// Note that the location might not exist.\n    pub fn base(&self) -> std::io::Result<PathBuf> {\n        Ok(gix_discover::path::without_dot_git_dir(self.dot_git()?))\n    }\n\n    /// The git directory for the work tree, typically contained within the parent git dir.\n    pub fn git_dir(&self) -> &Path {\n        &self.git_dir\n    }\n\n    /// The name of the worktree, which is derived from its folder within the `worktrees` directory within the parent `.git` folder.\n    pub fn id(&self) -> &BStr {\n        gix_path::os_str_into_bstr(self.git_dir.file_name().expect(\"worktrees/ parent dir\"))\n            .expect(\"no illformed UTF-8\")\n    }\n\n    /// Return true if the worktree cannot be pruned, moved or deleted, which is useful if it is located on an external storage device.\n    pub fn is_locked(&self) -> bool {\n        self.git_dir.join(\"locked\").symlink_metadata().is_ok()\n    }\n\n    /// Return true if this worktree can be pruned without an expiry grace period.\n    ///\n    /// Locked worktrees are never prunable. Otherwise, an unreadable `gitdir` file or missing target\n    /// makes the worktree prunable.\n    pub fn is_prunable(&self) -> bool {\n        !self.is_locked()\n            && self\n                .dot_git()\n                .map_or(true, |dot_git| dot_git.symlink_metadata().is_err())\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix/src/worktree/proxy.rs#L52-L88","documentation":"The second expect in `worktree::Proxy::id()`: `os_str_into_bstr(...).expect(\"no illformed UTF-8\")` panics when the worktree directory name cannot be represented as UTF-8-backed bytes. On Unix this means the directory name contains invalid UTF-8; on Windows, non-representable wide characters per the conversion rules.","triggerScenarios":"Calling `worktree::Proxy::id()` when the worktree's directory name under `worktrees/` contains non-UTF-8 bytes or unencodable characters.","commonSituations":"Linux filesystems allowing arbitrary bytes in names; worktrees created by non-UTF-8-aware scripts or third-party tools; locale mismatch when creating worktrees.","solutions":["Rename the worktree directory to a valid UTF-8 name (prefer `git worktree add` with ASCII names).","Validate the name: check `file_name().to_str().is_some()` before invoking worktree APIs.","Normalize tooling/locales that create worktrees so names are always UTF-8."],"exampleFix":"// before\nlet id = proxy.id(); // panics on non-UTF-8 dir name\n// after\nlet name = proxy.git_dir().file_name().and_then(|n| n.to_str());\nif name.is_none() { eprintln!(\"worktree name is not valid UTF-8\"); return; }\nlet id = proxy.id();","handlingStrategy":"validation","validationCode":"let ok = proxy.git_dir().file_name().map_or(false, |n| n.to_str().is_some());\nif !ok { return Err(anyhow::anyhow!(\"worktree name must be valid UTF-8\")); }\n","typeGuard":"fn utf8_named(p: &std::path::Path) -> bool { p.file_name().map_or(false, |n| n.to_str().is_some()) }\n","tryCatchPattern":null,"preventionTips":["Validate worktree names are UTF-8 at creation time","Avoid non-UTF-8 locales/scripts when creating worktrees","Prefer plain-ASCII worktree names for portability"],"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"}