Skip to content

go: preserve target compatibility on payload helpers - #270

Merged
tonyredondo merged 1 commit into
mainfrom
fix/go-helper-target-compatibility
Sep 23, 2026
Merged

tonyredondo merged 1 commit into
mainfrom
fix/go-helper-target-compatibility

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

Why

Marking the generated Go payload helpers manual kept them out of wildcard
build and test runs, but did not protect cquery //....

A consumer can make its optimized test incompatible when Test Optimization is
disabled. The macro already forwards that target_compatible_with value to
the public wrapper and hidden raw test, but not to the payload selector or
metadata helper. cquery can select those helpers independently and fail while
validating their disabled metadata repository.

Change

Forward the caller's target_compatible_with unchanged to both helpers.
The production change is two lines; lists, select(...), and composed
constraints keep their existing meaning.

Command Behavior with an incompatible optimized target
Wildcard build / test Manual helpers are not selected independently.
query Labels remain discoverable; manual is not a query filter.
Wildcard cquery The optimized target and helpers can be reported as incompatible without failing disabled-repository validation.
Explicit build / test Bazel rejects the incompatible target under its default settings. It does not run an ordinary test instead.

The consumer still owns the compatibility condition. This PR adds no enable
flag, environment variable, transition, or target-discovery query. Compatible
targets retain the existing repository enablement and identity checks.

Regression coverage

  • 34 attribute assertions cover static descriptors and generated exports with
    omitted, empty, literal, selected, and composed constraints, plus the disabled
    export's raw-test behavior.
  • A command-level regression reproduces wildcard cquery against a disabled
    repository, checks every returned configuration, exercises explicit-target
    failures, and verifies that opening the compatibility gate preserves strict
    metadata validation.
  • The new command-level test runs in the existing Ubuntu Go companion CI job.
  • The configuration reference explains the distinction between manual and
    compatibility, including what query and cquery return.

Validation

  • Before the fix: 12 helper-attribute assertions failed, and wildcard cquery
    failed with selected Test Optimization repository ... is disabled.
  • After the fix: all 135 Go companion tests passed, including the 34 new
    assertions; the command-level regression passed.
  • Buildifier, ShellCheck, and git diff --check passed.
  • The _tests Bzlmod monorepo runner passed against a local archive of this
    change: disabled mode, fresh/cached tests, doctor, mock uploads, and the full
    static .topt E2E. The ordinary uploader pass sent 8 test payloads and 12
    telemetry files successfully to the fixture server.
  • The _tests WORKSPACE monorepo runner is blocked before the enabled tests:
    GoSyntheticTestmainHelpers cannot find
    github.com/DataDog/dd-trace-go/v2/internal/civisibility/integrations/gotesting
    in v2.9.1. The same runner fails with the same error against unmodified rule
    main (42caa5c). This PR does not change the toolchain or dependency pins to
    work around that separate failure.

@tonyredondo
tonyredondo requested a review from a team as a code owner September 23, 2026 13:29

@datadog-prod-us1-3 datadog-prod-us1-3 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The helper targets now use the caller's compatibility constraint. The added coverage matches wildcard cquery and explicit-target behavior.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit e0e4f22 · @DataDog review to ask questions

@tonyredondo
tonyredondo merged commit f81024a into main Sep 23, 2026
62 checks passed
@tonyredondo
tonyredondo deleted the fix/go-helper-target-compatibility branch September 23, 2026 14:44
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.

2 participants