Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to non-existent named output should be an error #2948

Open
ajenkinski opened this issue Nov 8, 2023 · 1 comment
Open

Reference to non-existent named output should be an error #2948

ajenkinski opened this issue Nov 8, 2023 · 1 comment
Labels

Comments

@ajenkinski
Copy link

A reference to a non-existent rule produces an error in Please. However, a reference to a non-existent named output just silently succeeds with no output. I would think that referring to a non-existent named output should fail with a similar error.

For example, given this BUILD file in the root of a project.

text_file(name='hello', content='Hello')

export_file(
  name='bad-rule-ref',
  # Reference to non-existent rule, produces an error
  src='//:hola'
)
 
export_file(
  name='bad-named-output-ref',
  # The hello rule doesn't have named outputs, so this should result in an error but doesn't
  src='//:hello|foo'
)

I get this behavior:

bash-5.1$ plz build //:hello
Build finished; total time 60ms, incrementality 0.0%. Outputs:
//:hello:
  plz-out/gen/hello
bash-5.1$ plz build //:bad-rule-ref
Build stopped after 50ms. 1 target failed:
    //:hola
Target //:hola (referenced by //:bad-rule-ref) doesn't exist
bash-5.1$ plz build //:bad-named-output-ref 
Build finished; total time 40ms, incrementality 100.0%. Outputs:
//:bad-named-output-ref:
bash-5.1$ 

Note, when I try to build //:bad-rule-ref I get an error message, but when I build `//:bad-named-output-ref', it succeeds with the rule producing no output file. This can make a misspelling in a build file very hard to track down, since a misspelled named output won't produce any error at the actual source of the problem.

@Tatskaari Tatskaari added the bug label Dec 1, 2023
@Tatskaari
Copy link
Member

I had a crack at fixing this but it's quite a lot of work. It essentially requires a huge refactor of all the dependency resolution code. The annotated build labels are currently a concept of the build inputs, and are lost when we register dependencies to targets. I'll add this to the backlog, though we have some high priority work internally for the next quarter so might take a little time to get around to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants