From ece7dcfd232b780f5650326c8ac2379ca70387d4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 11 Jun 2026 08:52:01 +0300 Subject: Fix error wrapping: use %w for primary child error in tmux action In runInTmuxChild, the primary failure is the child runFn error; the echo-through failure is secondary context. Wrap the primary error with %w (keeping copyErr as %v, since fmt.Errorf allows only one %w) so errors.Is/As work across the chain. Audited all other fmt.Errorf %v/%s sites in internal/ and cmd/: they format strings, ints, status codes, or an []error aggregate (syncer), none of which is a single primary error to unwrap, so they stay as-is. Co-Authored-By: Claude Opus 4.8 --- internal/hexaiaction/cmdentry.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'internal/hexaiaction/cmdentry.go') diff --git a/internal/hexaiaction/cmdentry.go b/internal/hexaiaction/cmdentry.go index ee78307..85e9059 100644 --- a/internal/hexaiaction/cmdentry.go +++ b/internal/hexaiaction/cmdentry.go @@ -91,7 +91,10 @@ func runChild(ctx context.Context, infile, outfile string, stdout, stderr io.Wri if err := runFn(ctx, in, out, stderr); err != nil { closeOut() if copyErr := echoThrough(infile, tmp, os.Stdin, stdout); copyErr != nil { - return fmt.Errorf("hexai-tmux-action child: %v; echo failed: %v", err, copyErr) + // Wrap the primary child error with %w so callers can inspect it + // via errors.Is/As; the echo failure is secondary context and + // stays as %v (fmt.Errorf supports only a single %w). + return fmt.Errorf("hexai-tmux-action child: %w; echo failed: %v", err, copyErr) } } else { closeOut() -- cgit v1.2.3