From 9a2c8b615e9d56f5d8e679bd73c701daafc48f57 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 16 Dec 2025 11:16:46 -0500 Subject: [PATCH] Fix missing newlines in stderr error messages I happened to run `podman run --config=/path/to/file` and got an error without a trailing newline, which was a bit jarring. Fix the instances I noticed. Assisted-by: OpenCode (Claude Opus 4.5) Signed-off-by: Colin Walters --- cmd/podman-testing/store_supported.go | 2 +- cmd/podman/root.go | 6 +++--- cmd/podman/syslog_unsupported.go | 2 +- pkg/farm/farm.go | 2 +- test/e2e/run_test.go | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/podman-testing/store_supported.go b/cmd/podman-testing/store_supported.go index 6855645968..da70ce9c9e 100644 --- a/cmd/podman-testing/store_supported.go +++ b/cmd/podman-testing/store_supported.go @@ -42,7 +42,7 @@ func init() { func storeBefore() error { defaultStoreOptions, err := storage.DefaultStoreOptions() if err != nil { - fmt.Fprintf(os.Stderr, "selecting storage options: %v", err) + fmt.Fprintf(os.Stderr, "selecting storage options: %v\n", err) return nil } globalStorageOptions = defaultStoreOptions diff --git a/cmd/podman/root.go b/cmd/podman/root.go index ae9e0cf631..60d554f40a 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -443,16 +443,16 @@ func configHook() { if err != nil && !errors.Is(err, fs.ErrNotExist) { // Cases where the folder does not exist are allowed, BUT cases where some other Stat() error // is returned should fail - fmt.Fprintf(os.Stderr, "Supplied --config folder (%s) exists but is not accessible: %s", dockerConfig, err.Error()) + fmt.Fprintf(os.Stderr, "Supplied --config folder (%s) exists but is not accessible: %s\n", dockerConfig, err.Error()) os.Exit(1) } if err == nil && !statInfo.IsDir() { // Cases where it does exist but is a file should fail - fmt.Fprintf(os.Stderr, "Supplied --config file (%s) is not a directory", dockerConfig) + fmt.Fprintf(os.Stderr, "Supplied --config file (%s) is not a directory\n", dockerConfig) os.Exit(1) } if err := os.Setenv("DOCKER_CONFIG", dockerConfig); err != nil { - fmt.Fprintf(os.Stderr, "cannot set DOCKER_CONFIG=%s: %s", dockerConfig, err.Error()) + fmt.Fprintf(os.Stderr, "cannot set DOCKER_CONFIG=%s: %s\n", dockerConfig, err.Error()) os.Exit(1) } } diff --git a/cmd/podman/syslog_unsupported.go b/cmd/podman/syslog_unsupported.go index f65d624b3f..7136cbf6f2 100644 --- a/cmd/podman/syslog_unsupported.go +++ b/cmd/podman/syslog_unsupported.go @@ -15,6 +15,6 @@ func syslogHook() { return } - fmt.Fprintf(os.Stderr, "Logging to Syslog is not supported on %s", runtime.GOOS) + fmt.Fprintf(os.Stderr, "Logging to Syslog is not supported on %s\n", runtime.GOOS) os.Exit(1) } diff --git a/pkg/farm/farm.go b/pkg/farm/farm.go index cb936a856d..7eee696137 100644 --- a/pkg/farm/farm.go +++ b/pkg/farm/farm.go @@ -351,7 +351,7 @@ func (f *Farm) Build(ctx context.Context, schedule Schedule, options entities.Bu buildResults.Range(func(_, v any) bool { result, ok := v.(buildResult) if !ok { - fmt.Fprintf(os.Stderr, "report %v not a build result?", v) + fmt.Fprintf(os.Stderr, "report %v not a build result?\n", v) return false } perArchBuilds[result.report] = result.builder diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index cbb8dd5dd9..82fdb49755 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -101,7 +101,8 @@ var _ = Describe("Podman run", func() { tempFileName := tempFile.Name() session := podmanTest.Podman([]string{"--config", tempFileName, "run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitWithError(1, fmt.Sprintf(`Supplied --config file (%s) is not a directory`, tempFileName))) + // Note: ErrorToString() uses strings.Fields() which normalizes whitespace, so we're not testing the trailing newline + Expect(session).Should(ExitWithError(1, fmt.Sprintf("Supplied --config file (%s) is not a directory", tempFileName))) }) It("podman run from manifest list", func() {