bazelbuild / bazelbuild/bazel

TargetCompletedId#getAspect is inconsistent between TargetConfigured and TargetComplete events

Open
#14,266 0 comments 0 reactions 1 assignee Claimed by @michaeledgar View on GitHub
P2 team-Core type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

Given a dummy aspect:

```
def _dummy_aspect_impl(target, ctx):
return []

dummy_aspect = aspect(
implementation = _dummy_aspect_impl,
)
```

and passing `--aspect dummy_aspect.bzl%dummy-aspect` to a build invocation.

The `TargetConfigured`/`TargetComplete` events are inconsistent.

- `TargetConfiguredId` has `aspect == 'dummy_aspect.bzl%dummy-aspect'`, i.e. as given on the command line
- The `TargetCompletedId` inside `TargetConfigured#children` has `aspect == ''`, i.e. it is always blank
- The `TargetCompletedId` for `TargetComplete` has `aspect == '//:dummy_aspect.bzl%dummy-aspect'`, i.e. in canonical form

This means that you can't use `equals` on those `TargetCompletedId`s in order to know when a given aspect has finished.

I've worked around this in our build event service by taking the `aspect` from `TargetConfiguredId` and running it through the following logic. Any suggestions for improvement would be very welcome:

```
if (aspect.isEmpty() || aspect.startsWith("@") || aspect.startsWith("//")) {
return aspect;
}
return "//:" + aspect;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.