bazelbuild / bazelbuild/bazel

ConfiguredTargetFactory comments/logic wrongly suggest that a null ConfiguredTarget is always an error

Open
#17,915 2 comments 0 reactions 1 assignee Claimed by @tetromino View on GitHub
P3 team-Starlark-Integration type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

For native rules like genquery which perform significant work at analysis time, the rule's `create` may return a null `ConfiguredTarget` without setting a ruleContext error - and this is not an error, but signals a skyframe restart.

In that case, the intent is that `ConfiguredTargetFunction.createRule` return null, we eventually reach ConfiguredTargetFunction.java:376 where the env.valuesMissing() check will apply, and ConfiguredTargetFactory.compute() will return a null signaling a restart.

This means the comments in ConfiguredTargetFunction.erroredConfiguredTarget are misleading, and the `return target != null ? target : erroredConfiguredTarget(ruleContext, null)` logic seen in `ConfiguredTargetFunction.createRule` might lead to failure or crash if we (1) allow analysis failures and (2) encounter a skyframe restart in genquery.

CC @brandjon

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.