{"record":{"id":"c1997064d9ce55f1","repo":"vectordotdev/vector","slug":"non-utf8-path-to-pod-logs-dir-is-not-supported","errorCode":null,"errorMessage":"non-utf8 path to pod logs dir is not supported","messagePattern":"non-utf8 path to pod logs dir is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/kubernetes_logs/k8s_paths_provider.rs","lineNumber":158,"sourceCode":"        let escaped_container_name = glob::Pattern::escape(container);\n        glob::Pattern::new(&[pod_logs_dir, &escaped_container_name, \"**\"].join(\"/\")).ok()\n    })\n}\n\nfn list_pod_log_paths<'a, G, GI>(\n    mut glob_impl: G,\n    pod: &'a Pod,\n) -> impl Iterator<Item = PathBuf> + 'a\nwhere\n    G: FnMut(&str) -> GI + 'a,\n    GI: Iterator<Item = PathBuf> + 'a,\n{\n    extract_pod_logs_directory(pod)\n        .into_iter()\n        .flat_map(move |dir| {\n            let dir = dir\n                .to_str()\n                .expect(\"non-utf8 path to pod logs dir is not supported\");\n\n            // Run the glob to get a list of unfiltered paths.\n            let path_iter = glob_impl(\n                // We seek to match the paths like\n                // `<pod_logs_dir>/<container_name>/<n>.log` - paths managed by\n                // the `kubelet` as part of Kubernetes core logging\n                // architecture.\n                // In some setups, there will also be paths like\n                // `<pod_logs_dir>/<hash>.log` - those we want to skip.\n                &[dir, \"*/*.log*\"].join(\"/\"),\n            );\n\n            // Extract the containers to exclude, then build patterns from them\n            // and cache the results into a Vec.\n            let excluded_containers = extract_excluded_containers_for_pod(pod);\n            let exclusion_patterns: Vec<_> =\n                build_container_exclusion_patterns(dir, excluded_containers).collect();\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sources/kubernetes_logs/k8s_paths_provider.rs#L140-L176","documentation":"Panic from `Path::to_str()` in the kubernetes_logs source's path provider. Linux paths are byte strings; `to_str()` returns None when the pod logs directory (extracted from the pod spec, e.g. a custom log-dir annotation or hostPath volume mount under the kubelet logs root) contains bytes that are not valid UTF-8. The source asserts every such path is UTF-8 and panics otherwise, killing the kubernetes_logs path-provider iteration.","triggerScenarios":"`extract_pod_logs_directory(pod)` returns a PathBuf with non-UTF-8 bytes — e.g. a `vector.dev`-style log-dir annotation or a hostPath mount whose value was written in a legacy locale encoding or contains raw binary characters — and `dir.to_str()` returns None.","commonSituations":"Rare with stock kubelet directories (namespace/pod-uid/container are ASCII); seen with hand-crafted log-dir annotations, hostPath volumes with non-ASCII bytes, or tools that inject locale-encoded (e.g. Latin-1) strings into pod metadata.","solutions":["Identify the offending pod: audit pod annotations and volume hostPaths for non-UTF-8 values and fix the annotation/mount","Remove the custom log-dir override so the path derives from the ASCII pod UID under /var/log/pods","If embedding: use `to_string_lossy()` or skip the pod with a warning instead of `expect`"],"exampleFix":"// before\nlet dir = dir\n    .to_str()\n    .expect(\"non-utf8 path to pod logs dir is not supported\");\n// after\nlet Some(dir) = dir.to_str() else {\n    warn!(message = \"Skipping pod: logs directory is not valid UTF-8.\", path = ?dir);\n    return Vec::new().into_iter();\n};","handlingStrategy":"validation","validationCode":"// Rust: audit pod annotations/mounts before enabling kubernetes_logs\nlet dir = extract_pod_logs_directory(pod);\nif let Some(d) = &dir {\n    if d.to_str().is_none() {\n        warn!(message = \"pod logs dir is not UTF-8; pod will panic the source\", pod = %pod_uid);\n    }\n}","typeGuard":"fn is_utf8_path(path: &std::path::Path) -> bool {\n    path.to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Keep log-dir annotations and hostPath mounts strictly ASCII","Lint cluster metadata for non-UTF-8 bytes before installing kubernetes_logs","Prefer default kubelet paths (/var/log/pods/<ns>_<pod>/<uid>) over custom annotations"],"tags":["kubernetes","kubernetes-logs","path","utf-8","panic"],"backgroundTag":"non-utf8-path","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}