{"record":{"id":"9ee283e864b69211","repo":"vectordotdev/vector","slug":"not-a-valid-path","errorCode":null,"errorMessage":"not a valid path","messagePattern":"not a valid path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/file-source/src/file_server.rs","lineNumber":317,"sourceCode":"                            &buf.clone(),\n                            self.max_line_bytes,\n                            buf.len(),\n                        )\n                    });\n\n                    let sz = line.bytes.len();\n                    trace!(\n                        message = \"Read bytes.\",\n                        path = ?watcher.path,\n                        bytes = ?sz\n                    );\n                    stats.record_bytes(sz);\n\n                    bytes_read += sz;\n\n                    lines.push(Line {\n                        text: line.bytes,\n                        filename: watcher.path.to_str().expect(\"not a valid path\").to_owned(),\n                        file_id,\n                        start_offset: line.offset,\n                        end_offset: watcher.get_file_position(),\n                    });\n\n                    if bytes_read > self.max_read_bytes {\n                        maxed_out_reading_single_file = true;\n                        break;\n                    }\n                }\n                stats.record(\"reading\", start.elapsed());\n\n                if bytes_read > 0 {\n                    global_bytes_read = global_bytes_read.saturating_add(bytes_read);\n                } else {\n                    // Should the file be removed\n                    if let Some(grace_period) = self.remove_after\n                        && watcher.last_read_success().elapsed() >= grace_period","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/file-source/src/file_server.rs#L299-L335","documentation":"When the file server emits a read line it stores the watched file's path as a String via `Path::to_str()`, which returns None when the OS path bytes are not valid UTF-8. Vector unwraps this with expect(\"not a valid path\"), so a single non-UTF-8 filename inside a watched directory panics the file source mid-read. The panic happens while lines are being read from that file, not at watch time.","triggerScenarios":"A file whose name contains invalid UTF-8 bytes (for example b\"app\\xff.log\" written by a misconfigured uploader) matches an `include` glob of a `file` source; once the reader opens it and reads a line, watcher.path.to_str() returns None and the source panics.","commonSituations":"Log directories fed by third-party tools that write Latin-1/Windows-1252 or raw-byte filenames; files copied from systems with different encodings; containers with misconfigured locales producing byte names; files created by buggy log rotators or crash handlers.","solutions":["Locate and rename/remove the offending file: walk the watched tree and flag every path where `p.to_str().is_none()` (or use `find /var/log -name '*[![:print:]]*'`)","Tighten `include` / add `exclude_patterns` so the non-UTF-8 file falls outside the watched set","Fix the writer that produces the non-UTF-8 name so it stops recreating it"],"exampleFix":"# before: file named app$(printf '\\xff').log inside /var/log/app\nsudo mv /var/log/app/app$'\\xff'.log /tmp/quarantine/\n\n# or exclude it:\n[sources.in]\nexclude_patterns = [\"*[[:nonascii:]]*\"]  # or a wildcard that skips the directory","handlingStrategy":"validation","validationCode":"fn find_non_utf8_paths(roots: &[std::path::PathBuf]) -> Vec<std::path::PathBuf> {\n    walkdir::WalkDir::new(roots)\n        .into_iter()\n        .filter_map(Result::ok)\n        .filter(|e| e.path().to_str().is_none())\n        .map(|e| e.path().to_path_buf())\n        .collect()\n}\n// run before/at source start; rename or exclude anything it returns","typeGuard":"fn is_valid_utf8_path(path: &std::path::Path) -> bool {\n    path.to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Audit watched log directories for non-UTF-8 names after onboarding new log producers","Fix writers that emit raw-byte filenames (locale, encoding settings) instead of repeatedly renaming outputs","Scope include globs tightly so foreign directories cannot enter the watch set"],"tags":["rust","vector","file-source","utf-8","path","panic"],"backgroundTag":"non-utf8-file-path","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}