diff --git a/modules/mesh-build-go/cmd/mesh-build-go/run.go b/modules/mesh-build-go/cmd/mesh-build-go/run.go index 358dac35c..375394b67 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/run.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/run.go @@ -44,6 +44,13 @@ func (m *Module) run(ctx context.Context, fetch buildstep.StepFunc, a delivery.S return nil, err } ans.Built, ans.Key = built, key + // The answer is written on the step key as one value: one over the bus's value limit (the input's bound) fails the + // step, naming its size, before it is written. + if raw, err := json.Marshal(ans); err != nil { + return nil, err + } else if len(raw) > delivery.RunInputBound { + return nil, fmt.Errorf("the checking program's answer is %d bytes, over the bound of %d bytes a step key holds", len(raw), delivery.RunInputBound) + } return ans, nil } diff --git a/modules/mesh-build-go/cmd/mesh-build-go/run_test.go b/modules/mesh-build-go/cmd/mesh-build-go/run_test.go index 71c4a95eb..961991794 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/run_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/run_test.go @@ -95,6 +95,13 @@ func TestAKeptProgramIsRunOverItsHeadsAndInput(t *testing.T) { if ws < 0 || heads < ws || !strings.Contains(line, " "+delivery.RunHeadsEnv+" "+argv[heads+1]+" ") { t.Errorf("the heads are not bound read-only over the workspace: %s", line) } + // An answer over the bus's value limit fails the step, naming its size. + m.Run = func(context.Context, []string, string, ...string) forgekey.Ran { + return forgekey.Ran{Status: 0, Stdout: `"` + strings.Repeat("x", delivery.RunInputBound) + `"`} + } + if _, err := m.run(context.Background(), fetch, a); err == nil || !strings.Contains(err.Error(), "over the bound") { + t.Errorf("an answer over the bound: %v", err) + } m.Inside, m.Run = true, StepRunner(t.TempDir()) // An input other than the one named is refused, naming it. m.ReadInput = func(string, string) (json.RawMessage, error) { return json.RawMessage(`{"other":1}`), nil }