Better diagnostics for when empty digests / captures occur for adhoc_tool
, shell_command
, and friends
#21189
Replies: 1 comment
-
Better diagnostics is always better; your proposals about flags to control the warning behaviour on the relevant targets sounds good to me. Related prior example: #18183
I wonder whether we could get away with (implicitly)
Starting with
Sounds like that would help debugging 👍 I could imagine we might want to not print the full list in case its very large, but at least enough to give a sense of what's matching and what's not. |
Beta Was this translation helpful? Give feedback.
-
Background
The Problem
Pants does not error or warn when output digests captured by the shell backend or produced by the "wrap as" target types (e.g.,
experimental_wrap_as_resources
) are empty. This can occur, for example, because a file capture glob failed to capture a missing file foradhoc_tool
orshell_command
or the user specified an incorrect glob for theoutputs
field of a "wrap as" target type which was then not matched against the inputs.Motivation
As reported in #21156, a user recently encountered an issue where a file which they expected to be in the execution sandbox was missing. In their reproduction, the output digest of the relevant
shell_command
target was the pathcpp/hello_cpp
(but was captured via the glob"hello_cpp"
given theshell_command
's working directory wascpp
).The user then tried to use an
experimental_wrap_as_resources
target to convert that output into aresources
target for consumption by apython_test
target. Theoutputs
glob was specified ashello_cpp
and notcpp/hello_cpp
since the user was not aware of how the working directory support onshell_command
changes where the output is captured. This incorrect glob caused theexperimental_wrap_as_resources
to produce an empty digest as output.Pants did not provide any diagnostics to the user about this case. Arguably, Pants probably should provide some error or warning when globs do not match in these cases since the user clearly expected something to be there. Not doing so results in "silent failures" which are hard to debug if you are not a Pants maintainer. (Indeed, I had to add debug logging to rule code and run from Pants sources in order to track down the issue.)
Ideas
Some ideas for better diagnostics:
adhoc_tool
andshell_command
target types, Pants should by default verify that alloutput_files
andoutput_directories
globs in fact match captured files / directories from the process execution.Add an
outputs_match_error_behavior
field onadhoc_tool
andshell_command
which takes the valueserror
,warn
,ignore
to set what diagnostics occur if globs do not match.error
is the default.Add an
outputs_match_mode
field onadhoc_tool
andshell_command
which takes the valuesany
andall
to set whether at least one glob needs to match or whether all globs need to match.all
is the default.experimental_wrap_as_resources
), Pants should by default verify that theoutputs
globs in fact match files which produced by the input targets.outputs_match_error_behavior
field onadhoc_tool
andshell_command
which takes the valueserror
,warn
,ignore
to set what diagnostics occur if globs do not match.error
is the default.outputs_match_mode
field onadhoc_tool
andshell_command
which takes the valuesany
andall
to set whether at least one glob needs to match or whether all globs need to match.all
is the default.outputs_match_error_behavior
andoutputs_match_mode
? Or just rely on__defaults__
mechanism?adhoc_tool
,shell_command
, and "wrap_as" targets at debug level?Beta Was this translation helpful? Give feedback.
All reactions