Add an explicit error when trying to expand a Fileset outside of inputs list in
`Args.add_{all,joined}`.
When we declare Starlark action arguments as a lazy evaluation
(`Args.add_{all,joined}`), there is an option for tree artifacts and filesets
to be expanded (replaced by files belonging to them). Information about
expansion is based on the action inputs as that is execution-phase data. This
means that if we add a fileset to `Args` with `expand_directories=True` and
skip that from the action inputs, we will not have the ability to expand it at
the time of constructing the action command line. Currently, that results with
a `NullPointerException` due to a check in
[`ArtifactExpanderImpl`](https://github.com/bazelbuild/bazel/blob/280bbe244543ecf9d7dcb549f77e4c83fc600dca/src/main/java/com/google/devtools/build/lib/actions/Artifact.java#L265).
Change `ArtifactExpander::getFileSet` to throw a checked exception in case
expansion for a fileset is not available. Change existing uses, which should
always have the fileset expansion to crash on the new exception. Add an
explicit check for Starlark arguments to produce a user-facing error when we
cannot expand the fileset.
PiperOrigin-RevId: 331190722
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
index 99db6c2..bae61ac 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
@@ -2079,6 +2079,7 @@
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/actions:artifacts",
"//src/main/java/com/google/devtools/build/lib/actions:commandline_item",
+ "//src/main/java/com/google/devtools/build/lib/actions:fileset_output_symlink",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/concurrent",