From 6211a8fd6af1720eb8fdcc156e358900525bd1eb Mon Sep 17 00:00:00 2001 From: prql-bot <107324867+prql-bot@users.noreply.github.com> Date: Fri, 20 Nov 2026 06:58:37 +0000 Subject: [PATCH 1/2] fix: report a path with no .prql files in every prqlc command prqlc fmt on a file without a .prql extension, or a directory with no .prql files, exited successfully without doing anything, and lex, debug annotate and highlight said they found multiple sources. Report that no .prql files were found, naming the path, from read_files. --- prqlc/prqlc/src/cli/mod.rs | 5 +++++ prqlc/prqlc/src/cli/test.rs | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/prqlc/prqlc/src/cli/mod.rs b/prqlc/prqlc/src/cli/mod.rs index 823d4fe0a3fe..19fbaeb26ac7 100644 --- a/prqlc/prqlc/src/cli/mod.rs +++ b/prqlc/prqlc/src/cli/mod.rs @@ -625,6 +625,11 @@ fn read_files(input: &mut clio::ClioPath) -> Result { sources.insert(path, file_contents); } + if sources.is_empty() { + let error = + prqlc::Error::new_simple(format!("No `.prql` files found in `{}`", root.display())); + return Err(prqlc::ErrorMessages::from(error).into()); + } Ok(SourceTree::new(sources, Some(root.to_path_buf()))) } diff --git a/prqlc/prqlc/src/cli/test.rs b/prqlc/prqlc/src/cli/test.rs index c280410a3bd6..d2a2af3d208a 100644 --- a/prqlc/prqlc/src/cli/test.rs +++ b/prqlc/prqlc/src/cli/test.rs @@ -613,7 +613,36 @@ fn compile_no_prql_files() { ----- stdout ----- ----- stderr ----- - Error: No `.prql` files found in the source tree + Error: No `.prql` files found in `README.md` + "); +} + +#[test] +fn no_prql_files() { + let temp_dir = TempDir::new().expect("Failed to create temp directory"); + let txt = temp_dir.path().join("query.txt"); + std::fs::write(&txt, "from tracks\n").unwrap(); + + // `fmt` previously exited successfully without touching the file + assert_cmd_snapshot!(prqlc_command().args(["fmt", "query.txt"]).current_dir(temp_dir.path()), @" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + Error: No `.prql` files found in `query.txt` + "); + assert_eq!(std::fs::read_to_string(&txt).unwrap(), "from tracks\n"); + + // `lex` previously reported finding multiple sources + std::fs::create_dir(temp_dir.path().join("empty")).unwrap(); + assert_cmd_snapshot!(prqlc_command().args(["lex", "empty"]).current_dir(temp_dir.path()), @" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + Error: No `.prql` files found in `empty` "); } From b748faf7a859ce399554e7cebc87f28873de223c Mon Sep 17 00:00:00 2001 From: prql-bot <107324867+prql-bot@users.noreply.github.com> Date: Fri, 20 Nov 2026 06:58:48 +0000 Subject: [PATCH 2/2] docs: changelog for #6587 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e134271d6ae..fc91ad4db7fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,11 @@ **Fixes**: +- `prqlc fmt` on a file without a `.prql` extension, or a directory with no + `.prql` files, reports that no `.prql` files were found. It previously exited + successfully without formatting anything. `lex`, `debug annotate` and + `experimental highlight` report the same rather than claiming to have found + multiple sources. (@prql-bot, #6587) - `from_text format:json` with `columns` and `data` reports an error when a row has a different number of values than `columns`. It previously compiled to a `UNION ALL` with mismatched column counts. (@prql-bot, #6580)