{"record":{"id":"e9dd19a6f57649fb","repo":"jdx/mise","slug":"history-cannot-represent-a-non-utf-8-filename-ref","errorCode":null,"errorMessage":"history cannot represent a non-UTF-8 filename; refusing to change its bytes","messagePattern":"history cannot represent a non-UTF-8 filename; refusing to change its bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/tracked.rs","lineNumber":381,"sourceCode":"        // a hidden local-only history. Explicit encryption permits key files\n        // to be tracked without storing their plaintext.\n        walk.files.retain(|path, (_, policy)| {\n            if let Some(reason) = capture_exclusion(path, policy) {\n                walk.omitted.push(PathReason {\n                    path: display_path(path),\n                    reason: reason.into(),\n                });\n                false\n            } else {\n                true\n            }\n        });\n        walk.entries = set.entries.clone();\n        let config = normalize(&global_config_dir());\n        let mut roots: BTreeMap<String, CaptureRoot> = BTreeMap::new();\n        for (path, (owner, _)) in &walk.files {\n            if path.to_str().is_none() {\n                eyre::bail!(\n                    \"history cannot represent a non-UTF-8 filename; refusing to change its bytes\"\n                );\n            }\n            let (label, base, relative) = if let Ok(relative) = path.strip_prefix(&config) {\n                (\"config\", config.clone(), relative.to_path_buf())\n            } else if let Ok(relative) = path.strip_prefix(&home) {\n                (\"home\", home.clone(), relative.to_path_buf())\n            } else {\n                (\n                    \"fs\",\n                    PathBuf::from(std::path::MAIN_SEPARATOR.to_string()),\n                    path.components()\n                        .filter(|c| matches!(c, Component::Normal(_)))\n                        .collect(),\n                )\n            };\n            let label = walk.entries[*owner]\n                .variant","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/tracked.rs#L363-L399","documentation":"History storage represents file paths as UTF-8 strings; tracked::walk bails when a discovered tracked file path cannot be converted with Path::to_str(). Rather than silently mangling the file's bytes, it refuses to include it.","triggerScenarios":"Calling walk (directly or via list_commands, attempt_locked, live_tree, unsaved_paths) when any walked file path under the config dir or home fails `path.to_str().is_none()`, i.e. contains invalid UTF-8 bytes.","commonSituations":"Files created with legacy encodings or random-byte names on Linux (filenames are raw bytes); files restored from archives or other OSes with non-UTF-8 names inside a tracked directory.","solutions":["Rename the offending file to a UTF-8-safe name (`convmv` or manual mv).","Move the non-UTF-8 file out of the tracked/captured directories.","Exclude or delete the file if it is no longer needed."],"exampleFix":"// before: file named with raw bytes, e.g. created by `touch $'caf\\xe9'`\n// after: rename to valid UTF-8\nmv $'caf\\xe9' cafe.txt","handlingStrategy":"validation","validationCode":"if path.to_str().is_none() {\n  eprintln!(\"non-UTF-8 filename not supported: {:?}\", path);\n  return false;\n}","typeGuard":"fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }","tryCatchPattern":"match tracked::walk(...) {\n  Err(e) if e.to_string().contains(\"non-UTF-8 filename\") => rename_offenders(),\n  other => other?,\n}","preventionTips":["Only create files with ASCII/UTF-8 names in tracked directories.","Scan tracked dirs with `find . | grep -Pv '[\\x00-\\x7F]'` to spot offenders.","Use convmv when importing files from other encodings."],"tags":["filesystem","encoding","utf-8"],"backgroundTag":"invalid-argument-format","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}