Skip to content

Commit

Permalink
Emit a clearer error message when a mandatory output is missing from …
Browse files Browse the repository at this point in the history
…an ActionResult.

The remote execution spec allows an action to succeed, but produce only a subset of its declared outputs, so Bazel must verify that outputs marked as mandatory have been produced. Outputs are always mandatory except for a few specialized native actions (C++ and Java).

The current error message makes it sound like a programmer error rather than a user or rules author error.

See also bazelbuild/remote-apis#6 for the discussion that prompted this fix.

PiperOrigin-RevId: 586625265
Change-Id: I8846614917c82eff87c8495696e55b80c096c02c
  • Loading branch information
tjgq authored and copybara-github committed Nov 30, 2023
1 parent 4b13eee commit d34dc2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,7 @@ public InMemoryOutput downloadOutputs(RemoteAction action, RemoteActionResult re
&& !metadata.directories.containsKey(localPath)
&& !metadata.symlinks.containsKey(localPath)) {
throw new IOException(
"Invalid action cache entry "
+ action.getActionKey().getDigest().getHash()
+ ": expected output "
+ prettyPrint(output)
+ " does not exist.");
String.format("mandatory output %s was not created", prettyPrint(output)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ public void downloadOutputs_missingMandatoryOutputs_reportError() throws Excepti
IOException error =
assertThrows(IOException.class, () -> service.downloadOutputs(action, result));

assertThat(error).hasMessageThat().containsMatch("expected output .+ does not exist.");
assertThat(error).hasMessageThat().containsMatch("mandatory output .+ was not created");
}

@Test
Expand Down

0 comments on commit d34dc2a

Please sign in to comment.