Skip to content

fix(tfm_filegroup): always create _default target referenced by select() - #552

Open
brainoreally wants to merge 2 commits into
bazel-contrib:masterfrom
brainoreally:fix-tfm-filegroup-default-target
Open

fix(tfm_filegroup): always create _default target referenced by select()#552
brainoreally wants to merge 2 commits into
bazel-contrib:masterfrom
brainoreally:fix-tfm-filegroup-default-target

Conversation

@brainoreally

Copy link
Copy Markdown

Problem

tfm_filegroup() unconditionally references :_default as the //conditions:default fallback in multiple select() calls, but only created that target when default_to_empty=True. This causes "missing input file" errors when:

  • Using //... wildcard builds (e.g., bazel build //...)
  • Running in multi-platform configs where no TFM condition matches and the default case is evaluated

Root Cause

In nuget_archive.bzl, the _default empty filegroup was wrapped in:

if default_to_empty:
    native.filegroup(name = "%s_default" % name, srcs = [], ...)

However, default_to_empty=False is passed for libs and refs groups, yet their aliases still reference :_default unconditionally. The guard makes the fallback conditional while the references are not.

Fix

Remove the guard — always create _default regardless of default_to_empty.

This is safe because _default is always an empty filegroup (srcs=[]), serving only as a no-op fallback. Making it unconditional:

  • Fixes the build failure
  • Has zero semantic change to consumers (no extra files are selected)
  • Aligns with how the fallback was already unconditionally referenced

Related

Verification

Verified locally via downstream project (bazel build //...) and will be exercised by repo CI.

Cc: @purkhusid for review — primary maintainer of the nuget code.

tfm_filegroup() unconditionally references :<name>_default in select()
defaults, but only created it when default_to_empty=True. This causes
"missing input file" errors when analyzing targets with //... or in
multi-platform configurations where no TFM condition matches and the
default case is evaluated.

Making _default unconditional fixes the bug with no semantic change —
it's an empty filegroup that serves as a safe fallback.

Related: bazel-contrib#448
@brainoreally
brainoreally requested a review from purkhusid as a code owner July 31, 2026 00:22
After making _default unconditional, default_to_empty was no longer used
in tfm_filegroup(). Also removes it from _create_framework_select since
it was only ever used to pass it along to tfm_filegroup().
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