(665719e) Report an ambiguous search as an error, not a print and exit
resolve_ticket printed the candidate list to stdout and called process::exit(1) from inside a helper. That combination is the one thing the opencode wrapper cannot relay: it throws on the non-zero exit and keeps stderr, so the list was thrown away and the agent saw a bare exit code with nothing to choose from. Return an error carrying the rendered list instead. It reaches stderr the way every other error does, the exit code stays non-zero so `show x && ...` still fails, and no process::exit remains in util.rs. The wrapper half, which was dropping stderr on the floor regardless, follows in 3e8b6fa. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c675da1d2a
commit
a434f82928
+63
-14
@@ -64,6 +64,11 @@ fn get_stdout(cmd: &mut Command) -> String {
|
||||
String::from_utf8(assert.get_output().stdout.clone()).unwrap()
|
||||
}
|
||||
|
||||
fn get_stderr(cmd: &mut Command) -> String {
|
||||
let assert = cmd.assert();
|
||||
String::from_utf8(assert.get_output().stderr.clone()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_displays_ticket_by_full_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
@@ -256,13 +261,57 @@ fn show_asks_for_disambiguation_when_multiple_matches() {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("est");
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
assert!(stderr.contains("Test Ticket A"));
|
||||
assert!(stderr.contains("Test Ticket B"));
|
||||
assert!(stderr.contains("abc123d"));
|
||||
assert!(stderr.contains("fedcba0"));
|
||||
assert!(stderr.contains("Use the displayed ID"));
|
||||
}
|
||||
|
||||
/// The candidate list has to travel the same way every other error does, or the
|
||||
/// opencode wrapper throws on the exit code and discards it.
|
||||
#[test]
|
||||
fn show_reports_ambiguity_on_stderr_with_a_failing_exit() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Ambiguous One",
|
||||
"First.",
|
||||
"abc123def456789012345678901234567890",
|
||||
"alice",
|
||||
"2026-12-31",
|
||||
"test",
|
||||
);
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Ambiguous Two",
|
||||
"Second.",
|
||||
"fedcba0987654321fedcba09876543210987654321",
|
||||
"bob",
|
||||
"2026-10-15",
|
||||
"test",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
.arg("show")
|
||||
.arg("ambiguous")
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Ambiguous One"));
|
||||
assert!(stderr.contains("Ambiguous Two"));
|
||||
|
||||
// Nothing on stdout: that is where it used to go, and where it was lost
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Multiple tickets found"));
|
||||
assert!(stdout.contains("Test Ticket A"));
|
||||
assert!(stdout.contains("Test Ticket B"));
|
||||
assert!(stdout.contains("abc123d"));
|
||||
assert!(stdout.contains("fedcba0"));
|
||||
assert!(stdout.contains("Use the displayed ID"));
|
||||
assert!(stdout.is_empty(), "stdout was {stdout:?}");
|
||||
}
|
||||
|
||||
/// Filenames shorter than the displayed id width used to panic while printing
|
||||
@@ -286,10 +335,10 @@ fn show_disambiguates_tickets_with_short_filenames() {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("short");
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Multiple tickets found"));
|
||||
assert!(stdout.contains("Short One"));
|
||||
assert!(stdout.contains("Short Two"));
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
assert!(stderr.contains("Short One"));
|
||||
assert!(stderr.contains("Short Two"));
|
||||
}
|
||||
|
||||
/// A multibyte character straddling the cut used to panic.
|
||||
@@ -309,10 +358,10 @@ fn show_disambiguates_tickets_with_non_ascii_filenames() {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("accented");
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Multiple tickets found"));
|
||||
assert!(stdout.contains("Accented One"));
|
||||
assert!(stdout.contains("Accented Two"));
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
assert!(stderr.contains("Accented One"));
|
||||
assert!(stderr.contains("Accented Two"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user