Skip to content

Commit 34bd1ce

Browse files
authored
[fix] remove parse json (#737)
1 parent 1301b6e commit 34bd1ce

1 file changed

Lines changed: 0 additions & 17 deletions

File tree

pkg/module_manager/models/hooks/kind/batch_hook.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7-
"errors"
87
"fmt"
98
"log/slog"
109
"os"
@@ -187,22 +186,6 @@ func (h *BatchHook) Execute(ctx context.Context, configVersion string, bContext
187186
usage, err := cmd.RunAndLogLines(ctx, logLabels)
188187
result.Usage = usage
189188
if err != nil {
190-
outputError := &sdkhook.Error{}
191-
trimmed := strings.TrimPrefix(err.Error(), "stderr:")
192-
193-
// Try to parse stderr as a JSON error from the SDK.
194-
// If stderr contains non-JSON content (e.g. log lines before the JSON error),
195-
// fall back to returning the raw stderr content as the error message.
196-
jsonErr := json.NewDecoder(bytes.NewBufferString(trimmed)).Decode(outputError)
197-
if jsonErr != nil {
198-
h.Logger.Warn("json decode", slog.String("original", trimmed), log.Err(err))
199-
return result, fmt.Errorf("json decode: %w", jsonErr)
200-
}
201-
202-
if outputError.Message != "" {
203-
return result, errors.New(outputError.Message)
204-
}
205-
206189
return result, fmt.Errorf("run and log lines: %w", err)
207190
}
208191

0 commit comments

Comments
 (0)