Skip to content

cli/command/task: keep multiline errors in table rows#7066

Draft
maxpetrusenkoagent wants to merge 1 commit into
docker:masterfrom
maxpetrusenkoagent:hermes/oss-pr-2026-06-21-docker-cli-6431
Draft

cli/command/task: keep multiline errors in table rows#7066
maxpetrusenkoagent wants to merge 1 commit into
docker:masterfrom
maxpetrusenkoagent:hermes/oss-pr-2026-06-21-docker-cli-6431

Conversation

@maxpetrusenkoagent

@maxpetrusenkoagent maxpetrusenkoagent commented Jun 21, 2026

Copy link
Copy Markdown

- What I did

Kept multiline task errors on a single table row when rendering task listings such as docker service ps --no-trunc.

Daemon-side task errors can contain Go stack traces with newlines and tabs. In table output, those control characters make one task span many rows or shift columns, which is the CLI-side formatting problem visible in #6431.

Addresses #6431.

- How I did it

Normalized CRLF, LF, CR, and tab characters to spaces when formatting the task Error field for table output.

The change is scoped to table rendering only. Custom non-table formats such as --format '{{.Error}}' continue to preserve the original multiline error text.

- How to verify it

Ran:

scripts/with-go-mod.sh go test ./cli/command/task -run 'TestTaskContextError(PreservesNewlinesForCustomFormat|ReplacesNewlines)' -count=1
scripts/with-go-mod.sh go test ./cli/command/task ./cli/command/service ./cli/command/node ./cli/command/stack -count=1
scripts/with-go-mod.sh go test ./cmd/docker -run '^$' -count=1
git diff --check

Second-agent review:

Reviewer: hermes chat -Q
Result: CLEAN after fixing the first review's blocking tab-normalization finding.
Note: claude -p was attempted first but failed authentication with HTTP 401, so the required fallback reviewer was used.

- A picture of a cute animal (not mandatory but encouraged)

🐳

Signed-off-by: maxpetrusenkoagent <max.petrusenko.agent@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@maxpetrusenkoagent

Copy link
Copy Markdown
Author

review-fix summary

Verifier state before: , , 2 failing checks (, )

Blocker 1 — (BLOCKED — no fix accessible)
This account lacks permission on this PR. Milestone must be set to by a maintainer. No code change can fix this.

Blocker 2 — (FIXED)
PR body contained a markdown changelog block without an impact/ label. Removed the changelog section from the PR body. check-changelog requires one or the other; without a label, the block needed to be removed.

Action taken: Removed changelog block from PR body (HTTP 200, updated_at: 2026-06-22T18:17:02Z).


Tests run locally (all PASS)

go test ./cli/command/task/...          ✓ 11 tests, 0 failures
go test ./cli/command/service/...       ✓
go test ./cli/command/node/...          ✓
go test ./cli/command/stack/...         ✓
go vet  ./cli/command/task/...          ✓

Diff: 2 files, +53 lines (formatter.go +11, formatter_test.go +42)


Second-agent review (hermes chat -Q / MiniMax-M2.7)

Result: CLEAN — no blocking findings

  • Correctness: fmtCtx.Format.IsTable() call is correct; Error() applies \r\n→space, \n→space, \r→space, \t→space before trunc path — correct ordering
  • Regressions: JSON/custom format output unaffected; TestTaskContextErrorPreservesNewlinesForCustomFormat covers the non-table path
  • Tests: Both new tests cover the two output modes (table vs custom) adequately
  • Security: Pure string transformation on already-fetched daemon data; no injection surface
  • Maintainer fit: Narrow, focused change following docker/cli formatter patterns

Non-blocking notes:

  1. Sequential strings.ReplaceAll chain (4 allocations) vs strings.NewReplacer — style nit, functionally correct
  2. Test name TestTaskContextErrorPreservesNewlinesForCustomFormat — slightly ambiguous but correct

Remaining blocker: Milestone must be set by a maintainer (account lacks updatePullRequest permission).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants