{"record":{"id":"2623bd27b5549a6e","repo":"astral-sh/ruff","slug":"truth-source-directory-path-contains-invalid-u","errorCode":null,"errorMessage":"truth source directory `{path}` contains invalid UTF-8","messagePattern":"truth source directory `(.+?)` contains invalid UTF-8","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_completion_eval/src/main.rs","lineNumber":416,"sourceCode":"}\n\nimpl TaskSource {\n    fn all(src_dir: &SystemPath) -> anyhow::Result<Vec<TaskSource>> {\n        let mut sources = vec![];\n        let read_dir = src_dir\n            .as_std_path()\n            .read_dir()\n            .with_context(|| format!(\"failed to read directory entries in `{src_dir}`\"))?;\n        for result in read_dir {\n            let dent = result\n                .with_context(|| format!(\"failed to get directory entry from `{src_dir}`\"))?;\n            let path = dent.path();\n            if !path.is_dir() {\n                continue;\n            }\n\n            let dir = SystemPath::from_std_path(&path).ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"truth source directory `{path}` contains invalid UTF-8\",\n                    path = path.display()\n                )\n            })?;\n            sources.push(TaskSource::new(dir)?);\n        }\n        // Sort our sources so that we always run in the same order.\n        // And also so that the CSV output is deterministic across\n        // all platforms.\n        sources.sort_by(|source1, source2| source1.name.cmp(&source2.name));\n        Ok(sources)\n    }\n\n    fn new(dir: &SystemPath) -> anyhow::Result<TaskSource> {\n        let name = dir.file_name().ok_or_else(|| {\n            anyhow::anyhow!(\"truth source directory `{dir}` does not contain a base name\")\n        })?;\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty_completion_eval/src/main.rs#L398-L434","documentation":"`TaskSource::all` enumerates the subdirectories of `truth/` and converts each to a `SystemPath`; any directory whose name is not valid UTF-8 aborts the entire eval run with the offending path echoed via `display()`. This guards the whole harness up front so later steps can assume Unicode paths.","triggerScenarios":"A stray directory with non-UTF-8 bytes in its name inside `crates/ty_completion_eval/truth/` — OS droppings, editor artifacts, or extraction residue — gets enumerated and rejected.","commonSituations":"Developers or tools accidentally creating byte-named directories inside the repo; archives unpacked into the truth tree carrying mangled names.","solutions":["Find the offender: `find crates/ty_completion_eval/truth -mindepth 1 -maxdepth 1 -print0 | while IFS= read -r -d '' d; do printf '%s' \"$d\" | iconv -f utf-8 -t utf-8 >/dev/null 2>&1 || echo \"non-UTF-8: $d\"; done`","Remove or rename the offending directory (`git status crates/ty_completion_eval/truth` usually shows it as untracked)","Avoid unpacking third-party archives directly into the truth tree"],"exampleFix":"# before: run aborts with `truth source directory ... contains invalid UTF-8`\n# after: remove the stray directory, then re-run\nrm -r \"$(printf 'crates/ty_completion_eval/truff/bad\\xff')\" 2>/dev/null || true\ngit clean -fd crates/ty_completion_eval/truth\ncargo run -p ty_completion_eval -- all","handlingStrategy":"validation","validationCode":"find crates/ty_completion_eval/truth -mindepth 1 -maxdepth 1 -type d -print0 \\\n| while IFS= read -r -d '' d; do\n    printf '%s' \"$d\" | iconv -f utf-8 -t utf-8 >/dev/null 2>&1 \\\n      || echo \"non-UTF-8 fixture dir: $d\" >&2\n  done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the truth tree limited to committed, reviewed content","Do not unpack archives inside `truth/`","Run `git status` on the truth tree before eval runs to catch strays"],"tags":["unicode","evaluation","paths","repo-hygiene"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}