zellij-org/zellij · error
Not valid Utf8 Encoding
Error message
Not valid Utf8 Encoding
What it means
Converts the open-file payload's path from an OsString into a String with into_string().expect inside the server's editor-launch logic (the branch that builds +line arguments for vim/nvim/emacs/nano/kak and helix). into_string() returns Err when the path is not valid UTF-8 - arbitrary bytes on unix, unpaired surrogates on Windows - and the expect then panics the thread handling the open-file request. Real filesystems do contain such names, so a legal path hard-crashes the request.
Source
Thrown at zellij-server/src/os_input_output.rs:162
}
}
let mut command = default_editor.unwrap_or_else(|| {
PathBuf::from(
env::var("EDITOR")
.unwrap_or_else(|_| env::var("VISUAL").unwrap_or_else(|_| "vi".into())),
)
});
let mut args = vec![];
if !command.is_dir() {
separate_command_arguments(&mut command, &mut args);
}
let file_to_open = payload
.path
.into_os_string()
.into_string()
.expect("Not valid Utf8 Encoding");
if let Some(line_number) = payload.line_number {
if command.ends_with("vim")
|| command.ends_with("nvim")
|| command.ends_with("emacs")
|| command.ends_with("nano")
|| command.ends_with("kak")
{
failover_cmd_args = Some(vec![file_to_open.clone()]);
args.push(format!("+{}", line_number));
args.push(file_to_open);
} else if command.ends_with("hx") || command.ends_with("helix") {
// at the time of writing, helix only supports this syntax
// and it might be a good idea to leave this here anyway
// to keep supporting old versions
args.push(format!("{}:{}", file_to_open, line_number));
} else {
args.push(file_to_open);
}View on GitHub (pinned to 98a0837077)
Solutions
- Rename the offending file to valid UTF-8 (on unix: `convmv -f latin1 -t utf8 -r --notest <dir>`)
- Pass only UTF-8-clean paths to `zellij edit` and to plugins that open files
- Sanitize enumerated paths in plugins before issuing open-file actions
- Patch the call site to pass OsString args to Command or convert lossily with a warning instead of expect
Example fix
// before
let file_to_open = payload
.path
.into_os_string()
.into_string()
.expect("Not valid Utf8 Encoding");
// after - validate first and fail soft
let file_to_open = match payload.path.into_os_string().into_string() {
Ok(s) => s,
Err(os) => {
log::error!("non-UTF-8 path: {os:?}");
continue; // or use Command::arg(OsString) to keep the raw path
}
}; Defensive patterns
Strategy: validation
Validate before calling
use std::path::Path;
// before handing a path to the open-file / edit API
if payload.path.as_os_str().to_str().is_none() {
eprintln!("refusing non-UTF-8 path: {:?}", payload.path);
return;
} Type guard
use std::path::Path;
fn is_utf8_path(path: &Path) -> bool {
path.as_os_str().to_str().is_some()
} Try / catch
match payload.path.into_os_string().into_string() {
Ok(file_to_open) => { /* proceed */ }
Err(raw) => {
log::error!("skipping non-UTF-8 path {raw:?}");
// alternatively: std::process::Command::new(editor).arg(raw) keeps OsString args
}
} Prevention
- Keep filenames UTF-8 on machines that run zellij
- Use OsStr/OsString throughout paths that cross the FFI/IPC boundary
- Convert with to_string_lossy only for display, never for reopening files
- Test file-browsing plugins against a fixture directory of nasty filenames
When it happens
Trigger: `zellij edit <path>`, an open-file action, or a plugin-supplied path where the filename has non-UTF-8 bytes (legacy Latin-1/CP1252 names, malformed UTF-8, unpaired surrogate on Windows).
Common situations: Directories with files created by old archivers or other operating systems; restored backups preserving original byte names; cross-platform shares (smb/vfat) with odd codepages.
Related errors
- Could not find editor pane to replace - is no pane focused?
- Could not find editor pane to replace
- failed to find active pane id for client {client_id}
- no active pane for client {client_id}
- failed to find pane with id {pane_id:?}
AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16).
Data as JSON: /api/errors/3a619685d276324e.
Report an issue: GitHub.