Skip to content

fix(exec): reject empty command before executor setup#467

Open
not-matthias wants to merge 1 commit into
mainfrom
cod-3225-exec-empty-command-fail-fast
Open

fix(exec): reject empty command before executor setup#467
not-matthias wants to merge 1 commit into
mainfrom
cod-3225-exec-empty-command-fail-fast

Conversation

@not-matthias

Copy link
Copy Markdown
Member

codspeed exec with no command — and codspeed run with an empty or whitespace-only exec config target — built a BenchmarkTarget::Exec with an empty command. That empty target survived the full orchestrator (memtrack install, eBPF/libc uprobe attach, exec-harness spawn) before exec-harness rejected it with Empty command in stdin input, surfaced at the top level as the cryptic failed to execute memory tracker process: exit status: 1 after a ~2.3s probe detach.

The command is only ever supplied at two origins, so each is now validated up front — before any setup work:

  • CLI (codspeed exec): the positional command is now clap-required, so a missing command fails immediately at arg-parse with a usage message.
  • Config (codspeed run): build_benchmark_targets bails when a config exec command parses to zero words, naming the offending target.

Refs COD-3225

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

The PR moves empty exec-command validation ahead of orchestrator setup.

  • Makes the codspeed exec command positional required by Clap.
  • Validates exec targets before constructing the orchestrator.
  • Adds focused tests for missing and empty executable tokens.

Confidence Score: 4/5

The PR is not yet safe to merge because a whitespace-only CLI executable still bypasses the new early validation and reaches executor setup.

The guard checks is_empty() rather than whether the executable token is blank, so codspeed exec " " retains the delayed execution failure this change is intended to eliminate.

src/cli/exec/mod.rs

Important Files Changed

Filename Overview
src/cli/exec/mod.rs Adds early executable validation and regression tests, but the CLI path still accepts a whitespace-only executable token.

Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/cli/exec/mod.rs:153
**Whitespace-only executable bypasses validation**

When a user invokes `codspeed exec "   "`, Clap supplies a non-empty whitespace-only first token, so `exe.is_empty()` returns false and executor setup proceeds. The token is then sent to exec-harness as the program name and fails during process execution instead of being rejected up front.

Reviews (2): Last reviewed commit: "fix(exec): reject empty command before e..." | Re-trigger Greptile

Comment thread src/cli/exec/multi_targets.rs Outdated
TargetCommand::Exec { exec } => {
let command = shell_words::split(exec)
.with_context(|| format!("Failed to parse command: {exec}"))?;
if command.is_empty() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Empty executable token bypasses validation

When a config uses a quoted empty command such as exec: "''", shell_words::split produces a one-element vector containing an empty string, so this zero-length-vector check passes and the invalid executable reaches executor and harness setup, causing the same delayed process failure this change is intended to prevent. The CLI check has the same gap for codspeed exec ''.

Knowledge Base Used: CLI Commands

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/exec/multi_targets.rs
Line: 56

Comment:
**Empty executable token bypasses validation**

When a config uses a quoted empty command such as `exec: "''"`, `shell_words::split` produces a one-element vector containing an empty string, so this zero-length-vector check passes and the invalid executable reaches executor and harness setup, causing the same delayed process failure this change is intended to prevent. The CLI check has the same gap for `codspeed exec ''`.

**Knowledge Base Used:** [CLI Commands](https://app.greptile.com/codspeed/-/custom-context/knowledge-base/codspeedhq/codspeed/-/docs/cli-commands.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

@codspeed-hq

codspeed-hq Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing cod-3225-exec-empty-command-fail-fast (c4f262e) with main (26fb4b5)

Open in CodSpeed

`codspeed exec` with no command, and `codspeed run` with an empty or
whitespace-only `exec` target, built a BenchmarkTarget with an empty
command that only failed deep inside exec-harness ("Empty command in
stdin input"), surfaced as the cryptic "failed to execute memory
tracker process: exit status: 1" after a full memtrack probe attach.

Enforce a non-empty command at each origin: mark the exec positional
clap-required, and bail in build_benchmark_targets when a config exec
command parses to zero words.
@not-matthias
not-matthias force-pushed the cod-3225-exec-empty-command-fail-fast branch from 80723f5 to c4f262e Compare July 23, 2026 16:50
Comment thread src/cli/exec/mod.rs
let executor::BenchmarkTarget::Exec { command, name, .. } = target else {
continue;
};
if command.first().is_none_or(|exe| exe.is_empty()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Whitespace-only executable bypasses validation

When a user invokes codspeed exec " ", Clap supplies a non-empty whitespace-only first token, so exe.is_empty() returns false and executor setup proceeds. The token is then sent to exec-harness as the program name and fails during process execution instead of being rejected up front.

Knowledge Base Used: CLI Commands

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/exec/mod.rs
Line: 153

Comment:
**Whitespace-only executable bypasses validation**

When a user invokes `codspeed exec "   "`, Clap supplies a non-empty whitespace-only first token, so `exe.is_empty()` returns false and executor setup proceeds. The token is then sent to exec-harness as the program name and fails during process execution instead of being rejected up front.

**Knowledge Base Used:** [CLI Commands](https://app.greptile.com/codspeed/-/custom-context/knowledge-base/codspeedhq/codspeed/-/docs/cli-commands.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant