diff --git a/bib/pkg/progress/progress.go b/bib/pkg/progress/progress.go index 1e1a3a5..44f7da7 100644 --- a/bib/pkg/progress/progress.go +++ b/bib/pkg/progress/progress.go @@ -368,10 +368,12 @@ func runOSBuildWithProgress(pb ProgressBar, manifest []byte, store, outputDirect } wp.Close() + var statusErrs []error for { st, err := osbuildStatus.Status() if err != nil { - return fmt.Errorf("error reading osbuild status: %w", err) + statusErrs = append(statusErrs, err) + continue } if st == nil { break @@ -392,6 +394,9 @@ func runOSBuildWithProgress(pb ProgressBar, manifest []byte, store, outputDirect if err := cmd.Wait(); err != nil { return fmt.Errorf("error running osbuild: %w\nOutput:\n%s", err, stdio.String()) } + if len(statusErrs) > 0 { + return fmt.Errorf("errors parsing osbuild status:\n%w", errors.Join(statusErrs...)) + } return nil } diff --git a/bib/pkg/progress/progress_test.go b/bib/pkg/progress/progress_test.go index 31734ec..8bd2f93 100644 --- a/bib/pkg/progress/progress_test.go +++ b/bib/pkg/progress/progress_test.go @@ -140,7 +140,7 @@ func makeFakeOsbuild(t *testing.T, content string) string { return p } -func TestRunOSBuildWithProgress(t *testing.T) { +func TestRunOSBuildWithProgressErrorReporting(t *testing.T) { restore := progress.MockOsbuildCmd(makeFakeOsbuild(t, `echo osbuild-stdout-output >&2 echo osbuild-stderr-output exit 112 @@ -156,3 +156,17 @@ osbuild-stdout-output osbuild-stderr-output `) } + +func TestRunOSBuildWithProgressIncorrectJSON(t *testing.T) { + restore := progress.MockOsbuildCmd(makeFakeOsbuild(t, `echo osbuild-stdout-output +>&2 echo osbuild-stderr-output +>&3 echo invalid-json +`)) + defer restore() + + pbar, err := progress.New("debug") + assert.NoError(t, err) + err = progress.RunOSBuild(pbar, []byte(`{"fake":"manifest"}`), "", "", nil, nil) + assert.EqualError(t, err, `errors parsing osbuild status: +cannot scan line "invalid-json": invalid character 'i' looking for beginning of value`) +}