Skip to content

Drop doubled-package pseudo-labels from RuleInput before hashing - #288

Open
justinwon777 wants to merge 1 commit into
mainfrom
justin.won/label-fix
Open

Drop doubled-package pseudo-labels from RuleInput before hashing#288
justinwon777 wants to merge 1 commit into
mainfrom
justin.won/label-fix

Conversation

@justinwon777

@justinwon777 justinwon777 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Bazel query can render a workspace-relative string attribute (e.g. resource_strip_prefix, used by kt_jvm_library/java_library for resource stripping) as a pseudo-label. The result is a RuleInput entry like //pkg:pkg/resources that never corresponds to a real file, and HashRecursively's fallback for unresolved labels fails trying to stat the doubled path.

Filter such labels out of a rule's deps at proto-to-Target conversion time, since it's not a real label.

Real example: tooling/program-analysis/detekt/BUILD.bazel in Java monorepo:

uber_kt_library(
    name = "src_main",
    resource_strip_prefix = package_name() + "/src/main/resources",
    ...
)

bazel query adds resource_strip_prefix as a label-shaped RuleInput entry, formatted as //<current-package>:<raw-string>. Since the raw string is already workspace-rooted, the result doubles the package. The actual resource file is already part of the inputs

bazel query 'deps(//tooling/program-analysis/detekt:src_main, 1)' --output=label_kind:

source file //tooling/program-analysis/detekt:src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
source file //tooling/program-analysis/detekt:tooling/program-analysis/detekt/src/main/resources

Test Plan

unit test

Issue

https://linear.app/uber/issue/TANGO-33/fix-hasing-labels-with-package-prefixed

Bazel query can render a workspace-relative string attribute (e.g.
resource_strip_prefix, used by kt_jvm_library/java_library for
resource stripping) as a pseudo-label, naively prepending the current
package onto a value that already contains it. The result is a
RuleInput entry like //pkg:pkg/resources that never corresponds to a
real file, and HashRecursively's fallback for unresolved labels blows
up trying to stat the doubled path.

Filter such labels out of a rule's deps at proto-to-Target conversion
time, since a real Bazel label is never shaped this way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@justinwon777
justinwon777 requested review from a team as code owners August 22, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant