main.go error-color split breaks on multi-line error bodies #603

Closed
opened 2026-08-08 08:23:08 +00:00 by the.auditor · 1 comment
Owner

main() in cmd/tpagectl/main.go colors the first line of clierr.Render(err) red by splitting on the first \n. When the friendly status detail embeds a multi-line response body (a 5xx/401 with an indented or multi-line body), the split lands mid-error: only the first fragment gets the red style and the hint: line is folded into the remaining text via the second Fprintln. All text is still printed, but the styling and hint separation are mangled.

Split on the hint: marker (or color the whole message) instead of the first newline.

See #602

`main()` in `cmd/tpagectl/main.go` colors the first line of `clierr.Render(err)` red by splitting on the first `\n`. When the friendly status detail embeds a multi-line response body (a 5xx/401 with an indented or multi-line body), the split lands mid-error: only the first fragment gets the red style and the `hint:` line is folded into the remaining text via the second `Fprintln`. All text is still printed, but the styling and hint separation are mangled. Split on the `hint:` marker (or color the whole message) instead of the first newline. See https://git.lan.thwap.org/thwap/thwap-pagesd/pulls/602
Owner

Fixed in #634: main() colors only the leading error: prefix and prints the whole rendered message unchanged, so multi-line bodies and hint: lines are no longer mangled.

Fixed in #634: `main()` colors only the leading `error:` prefix and prints the whole rendered message unchanged, so multi-line bodies and `hint:` lines are no longer mangled.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd#603
No description provided.