From 7a84b6ada9944e0162f72f526bfd476008449abf Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 10 Jul 2024 12:34:05 +0200 Subject: [PATCH] osbuild-worker: tweak error to not include a \n for a failed stage Small followup for https://github.com/osbuild/osbuild-composer/pull/4113#discussion_r1670063775 Given that the failed stage is a relatively short string the `\n` seems unneccessary and quotes are enough. --- cmd/osbuild-worker/jobimpl-osbuild.go | 4 ++-- cmd/osbuild-worker/jobimpl-osbuild_test.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 54e2be8d82..282b7834d6 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -372,8 +372,8 @@ func makeJobErrorFromOsbuildOutput(osbuildOutput *osbuild.Result) *clienterrors. } reason := "osbuild build failed" - if len(failedStage) > 0 { - reason += " in stage:\n" + failedStage + if failedStage != "" { + reason += fmt.Sprintf(" in stage: %q", failedStage) } return clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, osbErrors) } diff --git a/cmd/osbuild-worker/jobimpl-osbuild_test.go b/cmd/osbuild-worker/jobimpl-osbuild_test.go index 5e65570632..818793874a 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild_test.go +++ b/cmd/osbuild-worker/jobimpl-osbuild_test.go @@ -34,8 +34,7 @@ func TestMakeJobErrorFromOsbuildOutput(t *testing.T) { }, }, }, - expected: `Code: 10, Reason: osbuild build failed in stage: -bad-stage, Details: []`, + expected: `Code: 10, Reason: osbuild build failed in stage: "bad-stage", Details: []`, }, { inputData: &osbuild.Result{