quaint-telephone-89068
01/15/2023, 4:06 PMpython_sources(
foo=["bar"]
)
Pants specifies the problematic BUILD file (Unrecognized field foo=['bar'] in target projectA:projectA):
[ERROR] 1 Exception encountered:
Engine traceback:
in `dependencies` goal
in Find targets from input specs
InvalidFieldException: Unrecognized field `foo=['bar']` in target projectA:projectA.
Valid fields for the target type `python_sources`... <redacted>
However, this is not always the case, e.g. having this declaration:
python_sources(
dependencies=[
"//::requirements#requests",
]
)
Pants would error with
[ERROR] 1 Exception encountered:
Engine traceback:
in `dependencies` goal
AddressParseException: Failed to parse address spec `//::requirements#requests`: error at 1:5: expected EOF
This is already great because //::requirements#requests could be `grep`ed in a large repo easily. However, it would be perhaps helpful to include the BUILD file path so a user knows where the problem exactly is.
There are some more generic errors, though:
python_sources(
sources=["//"]
)
Pants gives
[ERROR] 1 Exception encountered:
Engine traceback:
in `dependencies` goal
in Find targets from input specs
IntrinsicError: Absolute paths not supported: "//"
which is very hard to search in a large repo.
Describe the solution you'd like
It would be helpful to include the BUILD file path in more error messages when Pants fails to parse them. The work can be done in chunks as the parsing/normalization happens at different places in the codebase:
pants/src/rust/engine/fs/src/glob_matching.rs
Lines 124 to 134 in </pantsbuild/pants/commit/c60ea64d5e2ec76aad9853999acea1b2503a1f43|c60ea64>
pants/src/rust/engine/address/src/lib.rs
Lines 92 to 94 in </pantsbuild/pants/commit/8b2ead56de8467e1dfa76e09e93542ca12824082|8b2ead5>
Describe alternatives you've considered
I think specifying the BUILD file path where the problem is found is the only sensible way to help users find the location of the error.
pantsbuild/pants