Skip to content

Commit 357f069

Browse files
e_forbesclaude
andcommitted
Log original error before wrapping as APIError
When DoWithRetry fails, log the underlying error at ERROR level before replacing it with the generic "Internal API unreachable" APIError. This preserves the sanitised user-facing message while keeping the root cause visible in logs for debugging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9668e2f commit 357f069

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

internal/clients/gitlab/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import (
1111
"errors"
1212
"fmt"
1313
"io"
14+
"log/slog"
1415
"net/http"
1516
"path"
1617
"strings"
1718
"time"
1819

1920
"gitlab.com/gitlab-org/labkit/correlation"
21+
lablog "gitlab.com/gitlab-org/labkit/v2/log"
2022
"gitlab.com/gitlab-org/labkit/v2/httpclient"
2123

2224
"gitlab.com/gitlab-org/gitlab-shell/v14/client"
@@ -161,6 +163,7 @@ func (c *Client) do(ctx context.Context, method, apiPath string, data any) (*htt
161163

162164
resp, err := c.inner.DoWithRetry(req, nil)
163165
if err != nil {
166+
slog.ErrorContext(ctx, "Internal API unreachable", lablog.ErrorMessage(err.Error()))
164167
return nil, &client.APIError{Msg: "Internal API unreachable"}
165168
}
166169
return resp, nil

0 commit comments

Comments
 (0)