{"record":{"id":"3a619685d276324e","repo":"zellij-org/zellij","slug":"not-valid-utf8-encoding","errorCode":null,"errorMessage":"Not valid Utf8 Encoding","messagePattern":"Not valid Utf8 Encoding","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"zellij-server/src/os_input_output.rs","lineNumber":162,"sourceCode":"                }\n            }\n            let mut command = default_editor.unwrap_or_else(|| {\n                PathBuf::from(\n                    env::var(\"EDITOR\")\n                        .unwrap_or_else(|_| env::var(\"VISUAL\").unwrap_or_else(|_| \"vi\".into())),\n                )\n            });\n\n            let mut args = vec![];\n\n            if !command.is_dir() {\n                separate_command_arguments(&mut command, &mut args);\n            }\n            let file_to_open = payload\n                .path\n                .into_os_string()\n                .into_string()\n                .expect(\"Not valid Utf8 Encoding\");\n            if let Some(line_number) = payload.line_number {\n                if command.ends_with(\"vim\")\n                    || command.ends_with(\"nvim\")\n                    || command.ends_with(\"emacs\")\n                    || command.ends_with(\"nano\")\n                    || command.ends_with(\"kak\")\n                {\n                    failover_cmd_args = Some(vec![file_to_open.clone()]);\n                    args.push(format!(\"+{}\", line_number));\n                    args.push(file_to_open);\n                } else if command.ends_with(\"hx\") || command.ends_with(\"helix\") {\n                    // at the time of writing, helix only supports this syntax\n                    // and it might be a good idea to leave this here anyway\n                    // to keep supporting old versions\n                    args.push(format!(\"{}:{}\", file_to_open, line_number));\n                } else {\n                    args.push(file_to_open);\n                }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/zellij-org/zellij/blob/98a0837077492d53dd252ab30bc3e43e41e504f4/zellij-server/src/os_input_output.rs#L144-L180","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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"],"exampleFix":"// before\nlet file_to_open = payload\n    .path\n    .into_os_string()\n    .into_string()\n    .expect(\"Not valid Utf8 Encoding\");\n\n// after - validate first and fail soft\nlet file_to_open = match payload.path.into_os_string().into_string() {\n    Ok(s) => s,\n    Err(os) => {\n        log::error!(\"non-UTF-8 path: {os:?}\");\n        continue; // or use Command::arg(OsString) to keep the raw path\n    }\n};","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\n// before handing a path to the open-file / edit API\nif payload.path.as_os_str().to_str().is_none() {\n    eprintln!(\"refusing non-UTF-8 path: {:?}\", payload.path);\n    return;\n}","typeGuard":"use std::path::Path;\n\nfn is_utf8_path(path: &Path) -> bool {\n    path.as_os_str().to_str().is_some()\n}","tryCatchPattern":"match payload.path.into_os_string().into_string() {\n    Ok(file_to_open) => { /* proceed */ }\n    Err(raw) => {\n        log::error!(\"skipping non-UTF-8 path {raw:?}\");\n        // alternatively: std::process::Command::new(editor).arg(raw) keeps OsString args\n    }\n}","preventionTips":["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"],"tags":["rust","zellij","utf8","paths","filesystem","open-file"],"backgroundTag":null,"analyzedSha":"98a0837077492d53dd252ab30bc3e43e41e504f4","analyzedAt":"2026-08-16T13:02:01.396Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}