Fix managed process helper command serialization

This commit is contained in:
npc0-hue
2026-09-03 01:10:49 +08:00
parent 8de49f2dd3
commit 8ac45cf999
3 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -926,7 +926,7 @@ type ProcessCommand struct {
JobID string
Capability string
Action string
OutputLine func(string, string)
OutputLine func(string, string) `json:"-"`
}
type ProcessResult struct {
+16
View File
@@ -569,6 +569,22 @@ func TestOSProcessSupervisorRelaysRawCarriageReturn(t *testing.T) {
}
}
func TestProcessCommandJSONOmitsOutputCallback(t *testing.T) {
body, err := json.Marshal(ProcessCommand{
WorkDir: "/workspace",
Args: []string{"cmd.exe", "/d", "/c", "call", "start.cmd"},
OutputLine: func(stream string, line string) {
panic(stream + line)
},
})
if err != nil {
t.Fatalf("marshal process command with output callback: %v", err)
}
if strings.Contains(string(body), "OutputLine") || strings.Contains(string(body), "func") {
t.Fatalf("output callback leaked into helper JSON: %s", body)
}
}
type recordingLogSink struct {
mu sync.Mutex
lines []string