Fail a run step whose answer is over the bus's value limit, naming its size (issue 1921, review round 1)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user