fix: stop hard-exiting on unreadable directory and add #[must_use] to ContainerOutput

The validate subcommand was calling std::process::exit(1) when a
directory couldn't be read, which is a rather aggressive response
to a permission error. Especially when the code four lines above
handles a *missing* path by setting validation_failed and moving
on to the next one. Consistency is nice. Let's have some.

Split the match from the method chain (because continue is a
statement, not an expression, and Rust has opinions about that)
and replaced the exit(1) with the same continue pattern.

While at it, slap #[must_use] on ContainerOutput so the compiler
will yell at anyone who discards a run_container result without
checking exit_code. All current callers already bind it, so this
is purely forward-looking — but the kind of bug it prevents is
the silent-misexecution kind, and those are nobody's favorite.
This commit is contained in:
bahdotsh
2026-04-01 19:28:15 +05:30
parent 422a035c40
commit b49276a026
2 changed files with 15 additions and 12 deletions

View File

@@ -25,6 +25,7 @@ pub trait ContainerRuntime {
}
#[derive(Debug)]
#[must_use]
pub struct ContainerOutput {
pub stdout: String,
pub stderr: String,

View File

@@ -338,7 +338,7 @@ async fn main() {
if validate_path.is_dir() {
// Validate all workflow files in the directory
let entries = match std::fs::read_dir(&validate_path) {
let rd = match std::fs::read_dir(&validate_path) {
Ok(rd) => rd,
Err(e) => {
eprintln!(
@@ -346,18 +346,20 @@ async fn main() {
validate_path.display(),
e
);
std::process::exit(1);
validation_failed = true;
continue;
}
}
.filter_map(|entry| entry.ok())
.filter(|entry| {
entry.path().is_file()
&& entry
.path()
.extension()
.is_some_and(|ext| ext == "yml" || ext == "yaml")
})
.collect::<Vec<_>>();
};
let entries = rd
.filter_map(|entry| entry.ok())
.filter(|entry| {
entry.path().is_file()
&& entry
.path()
.extension()
.is_some_and(|ext| ext == "yml" || ext == "yaml")
})
.collect::<Vec<_>>();
println!(
"Validating {} workflow file(s) in {}...",