Skip to content

Commit c40e03b

Browse files
committed
"Action failed": highlight the action, not the command
We've found that when reading Buck2 error output, users often focus on the description of the action that failed ("Local command returned non-zero exit code 1"), which is the first part of the error message that's rendered in red text. Instead, we would like users to look at the name of the action that failed, which is rendered in bold text and often evades notice. - At the end of a failing Buck2 command, there's a section which recaps the errors encountered ("BUILD FAILED" "Failed to build 'root//src/Model:Model ...'"). This message is very legible and shows the failing target clearly, but users don't always see this message at first. The command may be long-running and the user may be reading output before it has finished, or the user may simply be reading the output top-to-bottom. - The description of the action that failed (currently rendered in red text) contains supplementary debugging information such as the failing command's exit code. It also prints the failing command (truncated), which is somewhat misleading; because Buck2 rules often invoke builds through layers of wrapper scripts, the failing command is rarely informative (e.g. a `ghc` failure does not show `ghc`, any wrapper script filename, or any source filenames in the truncated command). Although truncating the command is a good tradeoff for brevity, it is not the most informative part of the error message. Therefore, this change makes small adjustments to the styling of action errors: - The "Action failed" headline is rendered in bold red text, rather than bold white text. This helps draw the user's attention to the name of the action that failed, rather than the command that failed. This is the most important part of the change. - The reason ("Local command returned non-zero exit code 1") is still rendered in dark red text, as it provides context for _how_ the action failed. - The "Reproduce locally" line is rendered in white text, rather than dark red text.
1 parent 2555a25 commit c40e03b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

app/buck2_client_ctx/src/subscribers/superconsole.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ impl StatefulSuperConsoleImpl {
623623
StyledContent::new(
624624
ContentStyle {
625625
attributes: Attribute::Bold.into(),
626+
foreground_color: Some(Color::Red),
626627
..Default::default()
627628
},
628629
format!("Action failed: {action_id}",),
@@ -902,9 +903,9 @@ fn lines_for_command_details(
902903
}
903904
};
904905

905-
lines.push(Line::from_iter([Span::new_styled_lossy(
906-
format!("Reproduce locally: `{command}`").with(Color::DarkRed),
907-
)]));
906+
lines.push(Line::from_iter([Span::new_unstyled_lossy(format!(
907+
"Reproduce locally: `{command}`"
908+
))]));
908909
}
909910
Some(Command::RemoteCommand(remote_command)) => {
910911
let help_message = if buck2_core::is_open_source() {
@@ -937,9 +938,9 @@ fn lines_for_command_details(
937938
}
938939
};
939940

940-
lines.push(Line::from_iter([Span::new_styled_lossy(
941-
format!("Reproduce locally: `{command}`").with(Color::DarkRed),
942-
)]));
941+
lines.push(Line::from_iter([Span::new_unstyled_lossy(format!(
942+
"Reproduce locally: `{command}`"
943+
))]));
943944
}
944945
Some(Command::WorkerCommand(worker_command)) => {
945946
let command = worker_command_as_fallback_to_string(worker_command);
@@ -955,9 +956,9 @@ fn lines_for_command_details(
955956
}
956957
};
957958

958-
lines.push(Line::from_iter([Span::new_styled_lossy(
959-
format!("Reproduce locally: `{command}`").with(Color::DarkRed),
960-
)]));
959+
lines.push(Line::from_iter([Span::new_unstyled_lossy(format!(
960+
"Reproduce locally: `{command}`"
961+
))]));
961962
}
962963
};
963964
}

0 commit comments

Comments
 (0)