From a6a3d3f656f468066dd12e68ee61ee59e2a08fb4 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sat, 16 Nov 2024 08:36:57 +0100 Subject: [PATCH] Fix file watcher panic when event has no paths (#14364) --- crates/red_knot_workspace/src/watch/watcher.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/red_knot_workspace/src/watch/watcher.rs b/crates/red_knot_workspace/src/watch/watcher.rs index ef6ee2fdd2cd6..8cee2dd7b5578 100644 --- a/crates/red_knot_workspace/src/watch/watcher.rs +++ b/crates/red_knot_workspace/src/watch/watcher.rs @@ -210,7 +210,15 @@ impl Debouncer { } let kind = event.kind; - let path = match SystemPathBuf::from_path_buf(event.paths.into_iter().next().unwrap()) { + + // There are cases where paths can be empty. + // https://github.com/astral-sh/ruff/issues/14222 + let Some(path) = event.paths.into_iter().next() else { + tracing::debug!("Ignoring change event with kind '{kind:?}' without a path",); + return; + }; + + let path = match SystemPathBuf::from_path_buf(path) { Ok(path) => path, Err(path) => { tracing::debug!(