Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk-go): redact the base URL password in the retry log
Yudhi Armyndharise60c144330e8
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.goindex 2ae3f715d..9d97b007a 100644--- a/sdk/go/client_test.go+++ b/sdk/go/client_test.go@@ -1720,4 +1720,17 @@ func TestRequestLogRedactsBaseURLPassword(t *testing.T) {t.Errorf("request log = %q, want the URL without the password", got)}}++ // The retry layer logs the URL of every request it replays.+ lg := &argsLogger{}+ policy := RetryPolicy{MaxRetries: 1, BaseDelay: time.Millisecond, MaxDelay: time.Millisecond}+ c, err := New("https://proxyuser:[email protected]", "k",+ WithTransport(&statusTransport{status: 503}), WithLogger(lg), WithRetry(policy))+ if err != nil {+ t.Fatalf("New: %v", err)+ }+ _, _ = c.Health.Check(context.Background())+ if got := lg.text.String(); !strings.Contains(got, "openwa retrying request") || strings.Contains(got, "s3cret") {+ t.Errorf("retry log = %q, want the retry logged without the password", got)+ }}diff --git a/sdk/go/retry.go b/sdk/go/retry.goindex 560918d94..5729dec8b 100644--- a/sdk/go/retry.go+++ b/sdk/go/retry.go@@ -245,7 +245,7 @@ func retryMiddleware(p RetryPolicy, log Logger) Middleware {}log.Log(req.Context(), LevelWarn, "openwa retrying request",- "method", req.Method, "url", req.URL.String(),+ "method", req.Method, "url", req.URL.Redacted(),"attempt", attempt+1, "delay_ms", delay.Milliseconds())timer := time.NewTimer(delay)