<#18005 Include the name of the BUILD file that Pa...
# github-notifications
c
#18005 Include the name of the BUILD file that Pants failed to parse in the error message Issue created by AlexTereshenkov Is your feature request related to a problem? Please describe. When Pants parses a BUILD file, it often is very helpful telling where exactly the problem is, e.g. with
Copy code
python_sources(
  foo=["bar"]
)
Pants specifies the problematic BUILD file (
Unrecognized field foo=['bar'] in target projectA:projectA
):
Copy code
[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:
Copy code
python_sources(
  dependencies=[
     "//::requirements#requests",
  ]
)
Pants would error with
Copy code
[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:
Copy code
python_sources(
  sources=["//"]
)
Pants gives
Copy code
[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