Repository navigation
fix(notices): resolve GOROOT explicitly for go-licenses - #2159
Merged
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
Coverage Report ✅
Coverage BadgeNo Go source files changed in this PR. |
mchmarny
force-pushed
the
fix/go-licenses-empty-goroot
branch
from
August 11, 2026 16:26
6c7fd4d to
bc58c58
Compare
mchmarny
force-pushed
the
fix/go-licenses-empty-goroot
branch
from
August 11, 2026 16:39
bc58c58 to
858e665
Compare
go-licenses classifies a package as standard library by matching its
source path against go/build's GOROOT, which a Go binary only carries
when it was linked WITHOUT -trimpath. With GOFLAGS=-trimpath exported in
the environment, `go install go-licenses` yields a binary whose GOROOT is
empty: the stdlib prefix collapses to "/", every absolute source path
matches, and the tool reports the entire dependency graph as standard
library - writing nothing and exiting 0.
That silence surfaced two ways:
* `make tidy` died on an unrelated "cp: .../linux_amd64/.: No such file
or directory" when the notices generator merged a save_path that
go-licenses had never created.
* `make license-check` passed while inspecting zero packages - a silent
false PASS in a supply-chain gate.
Resolve GOROOT explicitly at both call sites so the outcome no longer
depends on how the binary happened to be built, and fail closed when a
per-platform save collects nothing.
CI installs go-licenses through a new install-go-licenses composite
action rather than duplicating the install inline in both merge-gate
jobs, keeping the GOFLAGS contract in one place.
Signed-off-by: Mark Chmarny <[email protected]>
mchmarny
force-pushed
the
fix/go-licenses-empty-goroot
branch
from
August 11, 2026 16:49
858e665 to
936d0b0
Compare
mchmarny
enabled auto-merge (squash)
August 11, 2026 16:52
dims
approved these changes
Aug 11, 2026
10 of 25 tasks
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
…d path The guards added with the GOROOT fix pass in states they exist to reject. - The install-action assertion did a whole-file `grep -q 'GOFLAGS= go install'`, which the action's own explanatory comment satisfies. Deleting `GOFLAGS=` from the real `run:` step left the suite green, so the -trimpath/empty-GOROOT regression could return undetected. Anchor the match to the executable line. - The inline-install scan required whitespace directly before the module path, so it matched only an unquoted `go install github.com/...`. Every install site in this repo quotes the path, so a quoted inline install in a workflow was not detected. Accept either quote form: matching only `"` would still let a single-quoted install through. The scan stays scoped to .github/workflows/ on purpose - the canonical action is where the real install lives, so widening the root would flag it as a violation of itself. - `make license-check` had no negative case. The stub go-licenses exits 0 unconditionally, so deleting the recipe's GOROOT validation branch left the suite green and only the export half was covered. Add a control that stubs `go env GOROOT` to print an unusable path while exiting 0. Exporting GOROOT=/nonexistent does not work: the real `go env` rejects it and exits 2, aborting the recipe under `set -e` before the branch is reached, which passes against a recipe with no validation at all. - The yq gate exited 0 for the whole file, discarding the license-check cases that never invoke the generator and so have no yq dependency. Locally that disabled every new assertion. Move the shared fixtures above the gate and run the license-check cases first, leaving the gate to guard only the generator. Follow-up to NVIDIA#2159. Signed-off-by: Yuan Chen <[email protected]>
This was referenced Aug 11, 2026
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
verify-licenses runs `make license-check`, gated on the `deps` paths-filter output. That filter matched go.mod, go.sum, vendor/**, and '.github/workflows/verify-licenses.yaml' - a file deleted in 3c9f6ec when the job was folded into merge-gate.yaml. The entry was never updated to follow it, so nothing in the filter watched any input the job actually consumes. A PR that changes the license gate therefore merges with the gate skipped. That happened on NVIDIA#2159, which repaired `make license-check` after finding it passed while inspecting zero packages: it rewrote the Makefile recipe and added the install-go-licenses action, and verify-licenses was skipped on it, so the repaired gate was never run against the real dependency graph before merging. Replace the dead entry and add every input that defines the check, mirroring the reasoning the sibling notices filter already documents ("a change to them must not be able to skip its own gate"): - Makefile - the license-check recipe is the gate's contract. - .github/actions/install-go-licenses/** - supplies the binary the check runs; that action clears GOFLAGS, without which -trimpath strips GOROOT and the check passes vacuously. - .github/workflows/merge-gate.yaml - now defines the job, and makes a change to the filter trigger the gate it controls. - .go-version, .settings.yaml, .github/actions/load-versions/** - the toolchain pins and the action that resolves them. The job reads both through load-versions before running the check, so a version bump would otherwise skip the gate it changes: NVIDIA#814 bumped go-licenses touching only .settings.yaml, and NVIDIA#1204 bumped Go touching only .go-version. Both would have run the license gate against a tool version it never validated. Fixes NVIDIA#2164. Signed-off-by: Yuan Chen <[email protected]>
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
verify-licenses runs `make license-check`, gated on the `deps` paths-filter output. That filter matched go.mod, go.sum, vendor/**, and '.github/workflows/verify-licenses.yaml' - a file deleted in 3c9f6ec when the job was folded into merge-gate.yaml. The entry was never updated to follow it, so nothing in the filter watched any input the job actually consumes. A PR that changes the license gate therefore merges with the gate skipped. That happened on NVIDIA#2159, which repaired `make license-check` after finding it passed while inspecting zero packages: it rewrote the Makefile recipe and added the install-go-licenses action, and verify-licenses was skipped on it, so the repaired gate was never run against the real dependency graph before merging. Replace the dead entry and add every input that defines the check, mirroring the reasoning the sibling notices filter already documents ("a change to them must not be able to skip its own gate"): - Makefile - the license-check recipe is the gate's contract. - .github/actions/install-go-licenses/** - supplies the binary the check runs; that action clears GOFLAGS, without which -trimpath strips GOROOT and the check passes vacuously. - .github/workflows/merge-gate.yaml - now defines the job, and makes a change to the filter trigger the gate it controls. - .go-version, .settings.yaml, .github/actions/load-versions/** - the toolchain pins and the action that resolves them. The job reads both through load-versions before running the check, so a version bump would otherwise skip the gate it changes: NVIDIA#814 bumped go-licenses touching only .settings.yaml, and NVIDIA#1204 bumped Go touching only .go-version. Both would have run the license gate against a tool version it never validated. Fixes NVIDIA#2164. Signed-off-by: Yuan Chen <[email protected]>
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
…d path The guards added with the GOROOT fix pass in states they exist to reject. - The install-action assertion did a whole-file `grep -q 'GOFLAGS= go install'`, which the action's own explanatory comment satisfies. Deleting `GOFLAGS=` from the real `run:` step left the suite green, so the -trimpath/empty-GOROOT regression could return undetected. Anchor the match to the executable line. - That assertion is a presence check: it proves at least one correct install exists, not that every install is. A second install line appended to the same action without `GOFLAGS=` would leave it green, and the workflow scan below deliberately does not cover .github/actions/, so nothing else would catch it. Reject any install line in the action that does not clear GOFLAGS. - The inline-install scan required whitespace directly before the module path, so it matched only an unquoted `go install github.com/...`. Every install site in this repo quotes the path, so a quoted inline install in a workflow was not detected. Accept either quote form: matching only `"` would still let a single-quoted install through. The scan stays scoped to .github/workflows/ on purpose - the canonical action is where the real install lives, so widening the root would flag it as a violation of itself. - `make license-check` had no negative case. The stub go-licenses exits 0 unconditionally, so deleting the recipe's GOROOT validation branch left the suite green and only the export half was covered. Add a control that stubs `go env GOROOT` to print an unusable path while exiting 0. Exporting GOROOT=/nonexistent does not work: the real `go env` rejects it and exits 2, aborting the recipe under `set -e` before the branch is reached, which passes against a recipe with no validation at all. - The yq gate exited 0 for the whole file, discarding the license-check cases that never invoke the generator and so have no yq dependency. Locally that disabled every new assertion. Move the shared fixtures above the gate and run the license-check cases first, leaving the gate to guard only the generator. Follow-up to NVIDIA#2159. Signed-off-by: Yuan Chen <[email protected]>
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
…d path The guards added with the GOROOT fix pass in states they exist to reject. - The install-action assertion did a whole-file `grep -q 'GOFLAGS= go install'`, which the action's own explanatory comment satisfies. Deleting `GOFLAGS=` from the real `run:` step left the suite green, so the -trimpath/empty-GOROOT regression could return undetected. Anchor the match to the executable line. - That assertion is a presence check: it proves at least one correct install exists, not that every install is. A second install line appended to the same action without `GOFLAGS=` would leave it green, and the workflow scan below deliberately does not cover .github/actions/, so nothing else would catch it. Reject any install line in the action that does not clear GOFLAGS. - The inline-install scan required whitespace directly before the module path, so it matched only an unquoted `go install github.com/...`. Every install site in this repo quotes the path, so a quoted inline install in a workflow was not detected. Accept either quote form: matching only `"` would still let a single-quoted install through. The scan stays scoped to .github/workflows/ on purpose - the canonical action is where the real install lives, so widening the root would flag it as a violation of itself. - `make license-check` had no negative case. The stub go-licenses exits 0 unconditionally, so deleting the recipe's GOROOT validation branch left the suite green and only the export half was covered. Add a control that stubs `go env GOROOT` to print an unusable path while exiting 0. Exporting GOROOT=/nonexistent does not work: the real `go env` rejects it and exits 2, aborting the recipe under `set -e` before the branch is reached, which passes against a recipe with no validation at all. - The yq gate exited 0 for the whole file, discarding the license-check cases that never invoke the generator and so have no yq dependency. Locally that disabled every new assertion. Move the shared fixtures above the gate and run the license-check cases first, leaving the gate to guard only the generator. Follow-up to NVIDIA#2159. Signed-off-by: Yuan Chen <[email protected]>
yuanchen8911
added a commit
to yuanchen8911/aicr
that referenced
this pull request
Aug 11, 2026
…d path The guards added with the GOROOT fix pass in states they exist to reject. - The install-action assertion did a whole-file `grep -q 'GOFLAGS= go install'`, which the action's own explanatory comment satisfies. Deleting `GOFLAGS=` from the real `run:` step left the suite green, so the -trimpath/empty-GOROOT regression could return undetected. Anchor the match to the executable line. - That assertion is a presence check: it proves at least one correct install exists, not that every install is. A second install line appended to the same action without `GOFLAGS=` would leave it green, and the workflow scan below deliberately does not cover .github/actions/, so nothing else would catch it. Reject any install line in the action that does not clear GOFLAGS. - The inline-install scan required whitespace directly before the module path, so it matched only an unquoted `go install github.com/...`. Every install site in this repo quotes the path, so a quoted inline install in a workflow was not detected. Accept either quote form: matching only `"` would still let a single-quoted install through. The scan stays scoped to .github/workflows/ on purpose - the canonical action is where the real install lives, so widening the root would flag it as a violation of itself. - `make license-check` had no negative case. The stub go-licenses exits 0 unconditionally, so deleting the recipe's GOROOT validation branch left the suite green and only the export half was covered. Add a control that stubs `go env GOROOT` to print an unusable path while exiting 0. Exporting GOROOT=/nonexistent does not work: the real `go env` rejects it and exits 2, aborting the recipe under `set -e` before the branch is reached, which passes against a recipe with no validation at all. - The yq gate exited 0 for the whole file, discarding the license-check cases that never invoke the generator and so have no yq dependency. Locally that disabled every new assertion. Move the shared fixtures above the gate and run the license-check cases first, leaving the gate to guard only the generator. Follow-up to NVIDIA#2159. Signed-off-by: Yuan Chen <[email protected]>
10 of 25 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go-licensessilently reports an empty dependency graph when its baked-inGOROOTis missing, which brokemake tidyand mademake license-checkpass while inspecting nothing. ResolveGOROOTexplicitly at both call sites and fail closed on an empty collection.Motivation / Context
go-licensesdecides whether a package is standard library by testing its source path againstgo/build'sGOROOT, and a Go binary only carries a baked-inGOROOTwhen it was linked without-trimpath. WithGOFLAGS=-trimpathexported in the environment (a common local default),go install go-licensesproduces a binary whoseGOROOTis empty. The stdlib prefix then collapses to/, every absolute source path matches, and the tool classifies the entire dependency graph as standard library — writing nothing and exiting0.That silence surfaced two ways:
make tidyfailed with an error that pointed nowhere near the cause:tools/generate-noticesmerged asave_paththatgo-licenses savehad never created.make license-checkpassed vacuously — a silent false PASS in a supply-chain gate. Reproduced onmain: the target exits0having inspected zero packages, so a disallowed license would not have been caught.Confirmed root cause by building the same probe with and without
-trimpath:Fixes: N/A
Related: #2158 — separate root cause (vendor path casing); both surfaced while running
make tidyafter13f6057d.Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)Implementation Notes
Fixing this at the call sites rather than only at install time is deliberate: it repairs already-installed binaries and any install path we do not control (a hand-run
go install, a runner whose environment carries-trimpath).GOROOTis derived fromgo env GOROOT, so it always matches the toolchain actually in use, including after aGOTOOLCHAINswitch.tools/generate-notices— resolve and exportGOROOT(validated non-empty and a real directory) before invokinggo-licenses.tools/generate-notices— fail closed when a per-platformsavecollects nothing, reporting the actual cause instead of a bareENOENTfrom the followingcp. An empty collection can no longer reach the notices file.Makefile(license-check) — same explicitGOROOTresolution, so the gate cannot pass vacuously..github/actions/install-go-licenses/— new composite action that installs the pinned version withGOFLAGScleared, matchingtools/setup-toolsand the convention already asserted bytools/setup-tools_test.sh. Both merge-gate jobs now call it instead of installing inline.CI installs
go-licensesthrough a newinstall-go-licensescomposite action instead of repeating the install inline in both merge-gate jobs, so theGOFLAGScontract lives in one place. It is a dedicated primitive rather than an addition tosetup-build-tools, because that action deliberately installs from binary releases ("go install puts in GOPATH which isn't in PATH") andgo-licensespublishes none.No Go source changed.
Testing
make qualify # exit 0Verification performed:
make tidynow exits0;make noticeswrites 204 Go modules + 130 Python packages.THIRD_PARTY_NOTICES.mdis byte-identical to the committed file, andmake notices-checkpasses.make license-checknow genuinely walks the dependency graph (emits per-package warnings for non-Go sources) and still passes.tools/generate-notices_test.sh, wired intomake test-shell→make test:go-licensesthat exits0and writes nothing (exactly the observed failure mode), the generator must exit non-zero, name the cause, and write no notices file.cp: ... No such file or directoryon the old code.GOROOTunset against a stub that records theGOROOTit actually received, so a bare assignment that is never exported fails the test. Verified by deletingexport GOROOTfrom the Makefile and fromtools/generate-noticesin turn — each deletion fails the suite (exit 1).GOFLAGS, and that no workflow installsgo-licensesinline without it. Both guards verified to fail against the pre-fix workflow.mikefarah/yqis absent, fails in CI — matchingtools/api-diff_test.sh.make qualifydetails: coverage 82.9% (threshold 80%), golangci-lint 0 issues, e2e chainsaw 24/24 passed, scan + api-diff clean.One unrelated flake was seen on the first
qualifyrun:tests/releasepolicy/TestReleaseResolverBehavior/Docker_manifest_list. It passes standalone on both this branch and pristinemain, and passed on re-run under the full suite — pre-existing timing sensitivity in a package this PR does not touch (parallelized recently in9198f361), not a regression from this change.Risk Assessment
Rollout notes: N/A — build tooling only, no runtime or released-artifact behavior change. Worth noting for reviewers:
license-checknow actually enforces the allowed-license policy, so it can legitimately start failing on a dependency that was previously waved through unexamined. It passes onmaintoday.Checklist
make testwith-race)make lint)git commit -S) — GPG signing info