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. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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_toolorshell_commandor the user specified an incorrect glob for theoutputsfield 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_commandtarget 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_resourcestarget to convert that output into aresourcestarget for consumption by apython_testtarget. Theoutputsglob was specified ashello_cppand notcpp/hello_cppsince the user was not aware of how the working directory support onshell_commandchanges where the output is captured. This incorrect glob caused theexperimental_wrap_as_resourcesto 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_toolandshell_commandtarget types, Pants should by default verify that alloutput_filesandoutput_directoriesglobs in fact match captured files / directories from the process execution.Add an
outputs_match_error_behaviorfield onadhoc_toolandshell_commandwhich takes the valueserror,warn,ignoreto set what diagnostics occur if globs do not match.erroris the default.Add an
outputs_match_modefield onadhoc_toolandshell_commandwhich takes the valuesanyandallto set whether at least one glob needs to match or whether all globs need to match.allis the default.experimental_wrap_as_resources), Pants should by default verify that theoutputsglobs in fact match files which produced by the input targets.outputs_match_error_behaviorfield onadhoc_toolandshell_commandwhich takes the valueserror,warn,ignoreto set what diagnostics occur if globs do not match.erroris the default.outputs_match_modefield onadhoc_toolandshell_commandwhich takes the valuesanyandallto set whether at least one glob needs to match or whether all globs need to match.allis the default.outputs_match_error_behaviorandoutputs_match_mode? Or just rely on__defaults__mechanism?adhoc_tool,shell_command, and "wrap_as" targets at debug level?All reactions