From 19994c1817bb24712b8498b4e9e1003d09eca0d1 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 10 Nov 2026 16:37:40 +0100 Subject: [PATCH] The fetch fails when the shut-off package load cannot run at all, naming the directory and go list's error (issue 1966, AC182-1) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- modules/mesh-build-go/cmd/mesh-build-go/fetch.go | 5 +++++ modules/mesh-build-go/cmd/mesh-build-go/fetch_test.go | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/fetch.go b/modules/mesh-build-go/cmd/mesh-build-go/fetch.go index aa9024e38..81e92c75b 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/fetch.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/fetch.go @@ -253,6 +253,11 @@ func (m *Module) shutOffLoad(ctx context.Context, env []string, dir, d string) e if len(lost) > 0 { return fmt.Errorf("the packages of %s load shut off only with what the fetch did not download: %s", d, strings.Join(lost, "; ")) } + // A load that could not run at all proves nothing: the fetch fails here, not a step later with less to say. + if r.Err != "" || r.Status != 0 { + say := strings.TrimSpace(r.Err + " " + r.Stderr) + return fmt.Errorf("the shut-off package load of %s could not run (exit %d): %s", d, r.Status, say) + } return nil } diff --git a/modules/mesh-build-go/cmd/mesh-build-go/fetch_test.go b/modules/mesh-build-go/cmd/mesh-build-go/fetch_test.go index 7b91bd94a..73bde7449 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/fetch_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/fetch_test.go @@ -215,6 +215,7 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) { const seatPkg = "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildgo" for _, c := range []struct { name, ran, out string + fatal bool want []string notWant string }{ @@ -225,11 +226,17 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) { {name: "the shut-off package load would reach the network", ran: "tools list -e -deps -test", out: "fixture/tools/cmd: \n" + seatPkg + ": module lookup disabled by GOPROXY=off\n", want: []string{"tools", "shut off", seatPkg + ": module lookup disabled by GOPROXY=off"}, notWant: "fixture/tools/cmd"}, + // 1966/AC182-1: a package load that could not run at all (a fatal exit, no GOPROXY=off line) fails the fetch too. + {name: "the shut-off package load cannot run", ran: "tools list -e -deps -test", fatal: true, + out: "go: go.mod file not found\n", want: []string{"tools", "go: go.mod file not found"}}, } { t.Run(c.name, func(t *testing.T) { f := &fakeStep{gomods: "go.mod\ntools/go.mod\n", goRule: func(line string) forgekey.Ran { if strings.Contains(line, "/"+c.ran) { if strings.Contains(line, " list ") { + if c.fatal { + return forgekey.Ran{Status: 1, Stderr: c.out} + } return forgekey.Ran{Stdout: c.out} // go list -e says a package's error and exits 0 } return forgekey.Ran{Status: 1, Stdout: c.out} @@ -249,7 +256,7 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) { t.Errorf("reason = %q, want it to hold %q", st.Reason, w) } } - if strings.Contains(st.Reason, c.notWant) { + if c.notWant != "" && strings.Contains(st.Reason, c.notWant) { t.Errorf("reason = %q holds %q", st.Reason, c.notWant) } if c.ran == "tools list -e -deps -test" {