Skip to content

Commit 7584cae

Browse files
committed
fix(cube-cli): don't report an unlistable validation failure twice
The empty-errors path printed a stderr line and then a bail! saying the same thing, unlike the error-list case where the stderr line heads a list. Keeping only the bail! leaves one line, and it's the more informative one — it says the API reported a failure without compilation errors, which is what points the operator at the runtime rather than the model.
1 parent a721ee6 commit 7584cae

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

rust/cube-cli/src/commands/validate.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,7 @@ pub async fn command(args: Args, ctx: &Ctx) -> Result<()> {
106106
Some(n) => output::success(&format!("Data model on {branch} is valid ({n} cubes)")),
107107
None => output::success(&format!("Data model on {branch} is valid")),
108108
}
109-
} else if errors.is_empty() {
110-
// A failure the API couldn't itemize. Saying "failed to compile:" here
111-
// would promise a list and then print nothing; point at the runtime
112-
// instead, which is where the answer actually is.
113-
eprintln!(
114-
"{} Data model on {branch} could not be validated.",
115-
"✗".red()
116-
);
117-
} else {
109+
} else if !errors.is_empty() {
118110
// Compilation errors go to stderr so `cube validate --json` stays
119111
// machine-readable on stdout and a human run stays readable when
120112
// stdout is piped.
@@ -127,6 +119,10 @@ pub async fn command(args: Args, ctx: &Ctx) -> Result<()> {
127119
if !valid {
128120
// Non-zero exit is the point of the command in CI, so it holds in
129121
// --json mode too, where the report above was printed as JSON.
122+
//
123+
// With nothing to list there is no stderr header above it: the header
124+
// exists to introduce a list, and repeating the verdict on two lines
125+
// says less than the one line that also says what to look at.
130126
if errors.is_empty() {
131127
bail!(
132128
"data model on {branch} could not be validated \

0 commit comments

Comments
 (0)