From f270282ee3a4081b031a1aa1b375b240a267d1b6 Mon Sep 17 00:00:00 2001 From: anaswara Date: Thu, 4 Jun 2026 15:36:23 +0530 Subject: [PATCH 1/7] open api logs added --- Nudr_DataRepository/api_default.go | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Nudr_DataRepository/api_default.go b/Nudr_DataRepository/api_default.go index 97c15557..06a07abd 100644 --- a/Nudr_DataRepository/api_default.go +++ b/Nudr_DataRepository/api_default.go @@ -24,6 +24,7 @@ import ( "github.com/antihax/optional" "github.com/5GC-DEV/openapi-cdac" + "github.com/5GC-DEV/openapi-cdac/logger" "github.com/5GC-DEV/openapi-cdac/models" ) @@ -4521,19 +4522,48 @@ func (a *DefaultApiService) PolicyDataUesUeIdSmDataGet(ctx context.Context, ueId localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + logger.OpenapiLog.Debugf( + "PolicyDataUesUeIdSmDataGet Request: ueId=%s path=%s query=%v", + ueId, + localVarPath, + localVarQueryParams.Encode(), + ) + r, err := openapi.PrepareRequest(ctx, a.client.cfg, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { + logger.OpenapiLog.Errorf( + "PrepareRequest failed ueId=%s err=%v", + ueId, + err, + ) return localVarReturnValue, nil, err } localVarHTTPResponse, err := openapi.CallAPI(a.client.cfg, r) if err != nil || localVarHTTPResponse == nil { + logger.OpenapiLog.Errorf( + "CallAPI failed ueId=%s err=%v rsp=%v", + ueId, + err, + localVarHTTPResponse, + ) return localVarReturnValue, localVarHTTPResponse, err } + logger.OpenapiLog.Errorf( + "UDR Response: status=%d %s", + localVarHTTPResponse.StatusCode, + localVarHTTPResponse.Status, + ) + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() if err != nil { + logger.OpenapiLog.Errorf( + "Read body failed ueId=%s err=%v", + ueId, + err, + ) return localVarReturnValue, localVarHTTPResponse, err } @@ -4542,20 +4572,49 @@ func (a *DefaultApiService) PolicyDataUesUeIdSmDataGet(ctx context.Context, ueId ErrorStatus: localVarHTTPResponse.Status, } + logger.OpenapiLog.Infof( + "UDR Raw Body UE=%s body=%s", + ueId, + string(localVarBody), + ) + switch localVarHTTPResponse.StatusCode { case 200: err = openapi.Deserialize(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { + logger.OpenapiLog.Errorf( + "Deserialize failed ueId=%s err=%v", + ueId, + err, + ) apiError.ErrorStatus = err.Error() } + logger.OpenapiLog.Errorf( + "Decoded SmPolicyData UE=%s data=%+v", + ueId, + localVarReturnValue, + ) return localVarReturnValue, localVarHTTPResponse, nil case 400: var v models.ProblemDetails + logger.OpenapiLog.Errorf( + "UDR returned 400 Bad Request, body=%s", + string(localVarBody), + ) err = openapi.Deserialize(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { + logger.OpenapiLog.Errorf( + "Failed to deserialize 400 response: err=%v body=%s", + err, + string(localVarBody), + ) apiError.ErrorStatus = err.Error() return localVarReturnValue, localVarHTTPResponse, apiError } + logger.OpenapiLog.Errorf( + "UDR 400 ProblemDetails: %+v", + v, + ) apiError.ErrorModel = v return localVarReturnValue, localVarHTTPResponse, apiError case 401: From fc77b7ccebafd82038cc8385655c2be0e5f4db96 Mon Sep 17 00:00:00 2001 From: anaswara Date: Mon, 8 Jun 2026 17:08:50 +0530 Subject: [PATCH 2/7] Retry mechanism added --- client.go | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 204 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index b8ba755a..77a38289 100644 --- a/client.go +++ b/client.go @@ -52,8 +52,27 @@ var ( innerHTTP2CleartextClient = &http.Client{ Transport: &http2.Transport{ AllowHTTP: true, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { + /*DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { return net.Dial(network, addr) + },*/ + DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { + logger.OpenapiLog.Infof( + "[HTTP2] Dial network=%s addr=%s", + network, + addr, + ) + + conn, err := net.Dial(network, addr) + + if err != nil { + logger.OpenapiLog.Errorf( + "[HTTP2] Dial failed addr=%s err=%v", + addr, + err, + ) + } + + return conn, err }, }, } @@ -129,7 +148,7 @@ func ParameterToString(obj interface{}, collectionFormat string) string { } // callAPI do the request. -func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { +/*func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { logger.OpenapiLog.Debugln("[CallAPI] Enter") if request == nil { @@ -157,8 +176,37 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { resp, err = innerHTTP2Client.Do(request) + if err != nil { + logger.OpenapiLog.Errorf("err type=%T err=%v", err, err) + + if ue, ok := err.(*url.Error); ok { + logger.OpenapiLog.Errorf( + "url.Error Op=%s URL=%s InnerType=%T InnerErr=%v", + ue.Op, + ue.URL, + ue.Err, + ue.Err, + ) + } + } + } else if request.URL.Scheme == "http" { logger.OpenapiLog.Debugln("[CallAPI] Using HTTP cleartext client") + resp, err = innerHTTP2CleartextClient.Do(request) + + if err != nil { + logger.OpenapiLog.Errorf("err type=%T err=%v", err, err) + + if ue, ok := err.(*url.Error); ok { + logger.OpenapiLog.Errorf( + "url.Error Op=%s URL=%s InnerType=%T InnerErr=%v", + ue.Op, + ue.URL, + ue.Err, + ue.Err, + ) + } + } resp, err = innerHTTP2CleartextClient.Do(request) @@ -189,6 +237,160 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { logger.OpenapiLog.Debugln("[CallAPI] Exit") + return resp, nil +}*/ + +func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { + logger.OpenapiLog.Debugln("[CallAPI] Enter") + + if request == nil { + logger.OpenapiLog.Errorln("[CallAPI] Request is nil") + return nil, fmt.Errorf("nil request") + } + + logger.OpenapiLog.Debugf("[CallAPI] Method: %s", request.Method) + logger.OpenapiLog.Debugf("[CallAPI] URL: %s", request.URL.String()) + logger.OpenapiLog.Debugf("[CallAPI] Scheme: %s", request.URL.Scheme) + logger.OpenapiLog.Debugf("[CallAPI] Host: %s", request.URL.Host) + logger.OpenapiLog.Debugf("[CallAPI] Path: %s", request.URL.Path) + + for key, value := range request.Header { + logger.OpenapiLog.Debugf("[CallAPI] Header %s: %v", key, value) + } + + var ( + resp *http.Response + err error + httpClient *http.Client + ) + + const maxRetries = 3 + + switch request.URL.Scheme { + + case "https": + logger.OpenapiLog.Debugln("[CallAPI] Using HTTPS client") + httpClient = innerHTTP2Client + + case "http": + logger.OpenapiLog.Debugln("[CallAPI] Using HTTP cleartext client") + httpClient = innerHTTP2CleartextClient + + default: + logger.OpenapiLog.Errorf( + "[CallAPI] Unsupported scheme: %s", + request.URL.Scheme, + ) + + return nil, fmt.Errorf( + "unsupported scheme[%s]", + request.URL.Scheme, + ) + } + + for attempt := 1; attempt <= maxRetries; attempt++ { + + resp, err = httpClient.Do(request) + + if err == nil { + break + } + + logger.OpenapiLog.Errorf( + "[CallAPI] attempt=%d/%d failed errType=%T err=%v", + attempt, + maxRetries, + err, + err, + ) + + if ue, ok := err.(*url.Error); ok { + + logger.OpenapiLog.Errorf( + "[CallAPI] url.Error Op=%s URL=%s InnerType=%T InnerErr=%v", + ue.Op, + ue.URL, + ue.Err, + ue.Err, + ) + + if unwrapped := errors.Unwrap(ue.Err); unwrapped != nil { + + logger.OpenapiLog.Errorf( + "[CallAPI] UnwrappedType=%T UnwrappedErr=%v", + unwrapped, + unwrapped, + ) + } + } + + // Retry only idempotent methods + switch request.Method { + + case http.MethodGet, + http.MethodHead, + http.MethodPut, + http.MethodDelete: + + default: + logger.OpenapiLog.Warnf( + "[CallAPI] Not retrying non-idempotent method=%s", + request.Method, + ) + + return resp, err + } + + if attempt < maxRetries { + + backoff := time.Duration(attempt*100) * time.Millisecond + + logger.OpenapiLog.Warnf( + "[CallAPI] Retrying after %v", + backoff, + ) + + time.Sleep(backoff) + } + } + + if err != nil { + logger.OpenapiLog.Errorf( + "[CallAPI] HTTP request failed after retries: %v", + err, + ) + + return resp, err + } + + if resp == nil { + logger.OpenapiLog.Errorln( + "[CallAPI] Received nil HTTP response", + ) + + return nil, fmt.Errorf("nil http response") + } + + logger.OpenapiLog.Debugf( + "[CallAPI] Response Status: %s", + resp.Status, + ) + + logger.OpenapiLog.Debugf( + "[CallAPI] Response Status Code: %d", + resp.StatusCode, + ) + + for key, value := range resp.Header { + logger.OpenapiLog.Debugf( + "[CallAPI] Response Header %s: %v", + key, + value, + ) + } + + logger.OpenapiLog.Debugln("[CallAPI] Exit") + return resp, nil } From 2e32180bc63043bd1021eac9c0cce8384a5565a0 Mon Sep 17 00:00:00 2001 From: anaswara Date: Fri, 12 Jun 2026 12:04:47 +0530 Subject: [PATCH 3/7] logs added --- client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 77a38289..ec3badb3 100644 --- a/client.go +++ b/client.go @@ -846,8 +846,17 @@ func Deserialize(v interface{}, b []byte, contentType string) (err error) { logger.OpenapiLog.Debugf("[Deserialize] String body: %s", *s) return nil } - + logger.OpenapiLog.Errorf( + "[Deserialize] contentType='%s' bodyLen=%d body='%s'", + contentType, + len(b), + string(b), + ) mediaType := KindOfMediaType(contentType) + logger.OpenapiLog.Errorf( + "[Deserialize] mediaType=%v", + mediaType, + ) logger.OpenapiLog.Debugf("[Deserialize] Detected media type: %v", mediaType) From 27b81785b4cd327eb9bcf16b355858ce887935d0 Mon Sep 17 00:00:00 2001 From: anaswara Date: Tue, 16 Jun 2026 18:02:54 +0530 Subject: [PATCH 4/7] logs added --- client.go | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index ec3badb3..3314b214 100644 --- a/client.go +++ b/client.go @@ -288,8 +288,35 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { ) } + if deadline, ok := request.Context().Deadline(); ok { + logger.OpenapiLog.Infof( + "[CallAPI] Initial Context Deadline=%v Remaining=%v", + deadline, + time.Until(deadline), + ) + } else { + logger.OpenapiLog.Infof( + "[CallAPI] Request has no context deadline", + ) + } + for attempt := 1; attempt <= maxRetries; attempt++ { + if deadline, ok := request.Context().Deadline(); ok { + logger.OpenapiLog.Infof( + "[CallAPI] Attempt=%d Method=%s RemainingContext=%v Deadline=%v", + attempt, + request.Method, + time.Until(deadline), + deadline, + ) + } + + logger.OpenapiLog.Infof( + "[CallAPI] HTTP Client Timeout=%v", + httpClient.Timeout, + ) + resp, err = httpClient.Do(request) if err == nil { @@ -304,6 +331,16 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { err, ) + logger.OpenapiLog.Errorf( + "[CallAPI] errors.Is(context.DeadlineExceeded)=%v", + errors.Is(err, context.DeadlineExceeded), + ) + + logger.OpenapiLog.Errorf( + "[CallAPI] errors.Is(context.Canceled)=%v", + errors.Is(err, context.Canceled), + ) + if ue, ok := err.(*url.Error); ok { logger.OpenapiLog.Errorf( @@ -314,8 +351,19 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { ue.Err, ) - if unwrapped := errors.Unwrap(ue.Err); unwrapped != nil { + if errors.Is(ue.Err, context.DeadlineExceeded) { + logger.OpenapiLog.Errorf( + "[CallAPI] Request context deadline exceeded", + ) + } + + if errors.Is(ue.Err, context.Canceled) { + logger.OpenapiLog.Errorf( + "[CallAPI] Request context cancelled", + ) + } + if unwrapped := errors.Unwrap(ue.Err); unwrapped != nil { logger.OpenapiLog.Errorf( "[CallAPI] UnwrappedType=%T UnwrappedErr=%v", unwrapped, From ecb870a5c29f888cd839cb894e729b94113746c3 Mon Sep 17 00:00:00 2001 From: anaswara Date: Fri, 19 Jun 2026 10:21:02 +0530 Subject: [PATCH 5/7] retrans parameter added --- client.go | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++- go.mod | 1 + go.sum | 2 + 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 3314b214..3ea95881 100644 --- a/client.go +++ b/client.go @@ -35,6 +35,7 @@ import ( "time" "github.com/5GC-DEV/openapi-cdac/logger" + "github.com/google/uuid" "golang.org/x/net/http2" "golang.org/x/oauth2" "gopkg.in/h2non/gock.v1" @@ -300,6 +301,37 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { ) } + var idempotencyKey string + + if isNonIdempotent(request.Method) { + + requestInfo := request.Header.Get("3gpp-Sbi-Request-Info") + + if requestInfo == "" { + + idempotencyKey = uuid.NewString() + + request.Header.Set( + "3gpp-Sbi-Request-Info", + fmt.Sprintf("idempotency-key=%s", idempotencyKey), + ) + + logger.OpenapiLog.Infof( + "[CallAPI] Generated IdempotencyKey=%s", + idempotencyKey, + ) + + } else { + + idempotencyKey = requestInfo + + logger.OpenapiLog.Infof( + "[CallAPI] Existing 3gpp-Sbi-Request-Info=%s", + requestInfo, + ) + } + } + for attempt := 1; attempt <= maxRetries; attempt++ { if deadline, ok := request.Context().Deadline(); ok { @@ -317,6 +349,25 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { httpClient.Timeout, ) + if attempt > 1 && + isNonIdempotent(request.Method) && + idempotencyKey != "" { + + request.Header.Set( + "3gpp-Sbi-Request-Info", + fmt.Sprintf( + "retrans=true; idempotency-key=%s", + idempotencyKey, + ), + ) + + logger.OpenapiLog.Infof( + "[CallAPI] Retry attempt=%d with SBI Request Info=%s", + attempt, + request.Header.Get("3gpp-Sbi-Request-Info"), + ) + } + resp, err = httpClient.Do(request) if err == nil { @@ -373,7 +424,7 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { } // Retry only idempotent methods - switch request.Method { + /*switch request.Method { case http.MethodGet, http.MethodHead, @@ -398,6 +449,30 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { backoff, ) + time.Sleep(backoff) + }*/ + if !shouldRetry(request.Method, err) { + logger.OpenapiLog.Warnf( + "[CallAPI] Retry not allowed method=%s err=%v", + request.Method, + err, + ) + + return resp, err + } + if attempt < maxRetries { + + if request.GetBody != nil { + request.Body, _ = request.GetBody() + } + + backoff := time.Duration(attempt*100) * time.Millisecond + + logger.OpenapiLog.Warnf( + "[CallAPI] Retrying after %v", + backoff, + ) + time.Sleep(backoff) } } @@ -1106,3 +1181,44 @@ func InterceptH2CClient() { func RestoreH2CClient() { gock.RestoreClient(innerHTTP2CleartextClient) } + +func shouldRetry(method string, err error) bool { + if err == nil { + return false + } + + // Idempotent methods + switch method { + case http.MethodGet, + http.MethodHead, + http.MethodPut, + http.MethodDelete: + return true + } + + // Non-idempotent POST + if method == http.MethodPost { + errStr := err.Error() + + // RFC7540 / 3GPP TS 29.500 allowed retry cases + if strings.Contains(errStr, "REFUSED_STREAM") { + return true + } + + if strings.Contains(errStr, "GOAWAY") { + return true + } + } + + return false +} + +func isNonIdempotent(method string) bool { + switch method { + case http.MethodPost, + http.MethodPatch: + return true + default: + return false + } +} diff --git a/go.mod b/go.mod index 42380088..d88145ca 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/uuid v1.6.0 github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect diff --git a/go.sum b/go.sum index 615b0b13..af0e5cea 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= From 5a3dc24074275a5b0e243af1249963e9d60e147d Mon Sep 17 00:00:00 2001 From: anaswara Date: Fri, 19 Jun 2026 17:28:52 +0530 Subject: [PATCH 6/7] client conn could not be established retry added --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index 3ea95881..39a79205 100644 --- a/client.go +++ b/client.go @@ -1208,6 +1208,14 @@ func shouldRetry(method string, err error) bool { if strings.Contains(errStr, "GOAWAY") { return true } + + if strings.Contains(errStr, "client conn could not be established") { + logger.OpenapiLog.Warn( + "[CallAPI] Retrying POST due to connection establishment failure", + ) + return true + } + } return false From fcfd9c9aecfe767544f0a4388dfd47a44cc4b872 Mon Sep 17 00:00:00 2001 From: anaswara Date: Wed, 1 Jul 2026 15:18:37 +0530 Subject: [PATCH 7/7] removed commented code --- client.go | 125 ------------------------------------------------------ 1 file changed, 125 deletions(-) diff --git a/client.go b/client.go index 39a79205..6fce6d77 100644 --- a/client.go +++ b/client.go @@ -53,9 +53,6 @@ var ( innerHTTP2CleartextClient = &http.Client{ Transport: &http2.Transport{ AllowHTTP: true, - /*DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - return net.Dial(network, addr) - },*/ DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { logger.OpenapiLog.Infof( "[HTTP2] Dial network=%s addr=%s", @@ -148,99 +145,6 @@ func ParameterToString(obj interface{}, collectionFormat string) string { return fmt.Sprintf("%v", obj) } -// callAPI do the request. -/*func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { - logger.OpenapiLog.Debugln("[CallAPI] Enter") - - if request == nil { - logger.OpenapiLog.Errorln("[CallAPI] Request is nil") - return nil, fmt.Errorf("nil request") - } - - logger.OpenapiLog.Debugf("[CallAPI] Method: %s", request.Method) - logger.OpenapiLog.Debugf("[CallAPI] URL: %s", request.URL.String()) - logger.OpenapiLog.Debugf("[CallAPI] Scheme: %s", request.URL.Scheme) - logger.OpenapiLog.Debugf("[CallAPI] Host: %s", request.URL.Host) - logger.OpenapiLog.Debugf("[CallAPI] Path: %s", request.URL.Path) - - for key, value := range request.Header { - logger.OpenapiLog.Debugf("[CallAPI] Header %s: %v", key, value) - } - - var ( - resp *http.Response - err error - ) - - if request.URL.Scheme == "https" { - logger.OpenapiLog.Debugln("[CallAPI] Using HTTPS client") - - resp, err = innerHTTP2Client.Do(request) - - if err != nil { - logger.OpenapiLog.Errorf("err type=%T err=%v", err, err) - - if ue, ok := err.(*url.Error); ok { - logger.OpenapiLog.Errorf( - "url.Error Op=%s URL=%s InnerType=%T InnerErr=%v", - ue.Op, - ue.URL, - ue.Err, - ue.Err, - ) - } - } - - } else if request.URL.Scheme == "http" { - logger.OpenapiLog.Debugln("[CallAPI] Using HTTP cleartext client") - resp, err = innerHTTP2CleartextClient.Do(request) - - if err != nil { - logger.OpenapiLog.Errorf("err type=%T err=%v", err, err) - - if ue, ok := err.(*url.Error); ok { - logger.OpenapiLog.Errorf( - "url.Error Op=%s URL=%s InnerType=%T InnerErr=%v", - ue.Op, - ue.URL, - ue.Err, - ue.Err, - ) - } - } - - resp, err = innerHTTP2CleartextClient.Do(request) - - } else { - logger.OpenapiLog.Errorf("[CallAPI] Unsupported scheme: %s", - request.URL.Scheme) - - return nil, fmt.Errorf("unsupported scheme[%s]", - request.URL.Scheme) - } - - if err != nil { - logger.OpenapiLog.Errorf("[CallAPI] HTTP request failed: %v", err) - return resp, err - } - - if resp == nil { - logger.OpenapiLog.Errorln("[CallAPI] Received nil HTTP response") - return nil, fmt.Errorf("nil http response") - } - - logger.OpenapiLog.Debugf("[CallAPI] Response Status: %s", resp.Status) - logger.OpenapiLog.Debugf("[CallAPI] Response Status Code: %d", resp.StatusCode) - - for key, value := range resp.Header { - logger.OpenapiLog.Debugf("[CallAPI] Response Header %s: %v", key, value) - } - - logger.OpenapiLog.Debugln("[CallAPI] Exit") - - return resp, nil -}*/ - func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { logger.OpenapiLog.Debugln("[CallAPI] Enter") @@ -422,35 +326,6 @@ func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error) { ) } } - - // Retry only idempotent methods - /*switch request.Method { - - case http.MethodGet, - http.MethodHead, - http.MethodPut, - http.MethodDelete: - - default: - logger.OpenapiLog.Warnf( - "[CallAPI] Not retrying non-idempotent method=%s", - request.Method, - ) - - return resp, err - } - - if attempt < maxRetries { - - backoff := time.Duration(attempt*100) * time.Millisecond - - logger.OpenapiLog.Warnf( - "[CallAPI] Retrying after %v", - backoff, - ) - - time.Sleep(backoff) - }*/ if !shouldRetry(request.Method, err) { logger.OpenapiLog.Warnf( "[CallAPI] Retry not allowed method=%s err=%v",