Copilot commented on code in PR #21:
URL: 
https://github.com/apache/incubator-seata-ctl/pull/21#discussion_r3845605845


##########
seata/config.go:
##########
@@ -115,7 +115,7 @@ func ReloadConfiguration() {
        request, _ := http.NewRequest("POST", url, nil)
        request.Header.Set("authorization", token)
        request.Header.Set("Content-Type", "application/json")
-       resp, err := (&http.Client{}).Do(request)
+       resp, err := defaultHTTPClient.Do(request)
        if err != nil {

Review Comment:
   `http.NewRequest` errors are ignored here. If the URL is invalid, `request` 
will be nil and `request.Header.Set(...)` will panic. Handle the request 
creation error and return early.



##########
seata/txn.go:
##########
@@ -41,7 +41,7 @@ func BeginTxn(timeout int) {
        }
        request, _ := http.NewRequest("POST", url, nil)
        request.Header.Set("authorization", token)
-       resp, err := (&http.Client{}).Do(request)
+       resp, err := defaultHTTPClient.Do(request)
        if err != nil {

Review Comment:
   `http.NewRequest` errors are ignored here. If the constructed URL is invalid 
(e.g., misconfigured address containing spaces), `request` will be nil and the 
subsequent `request.Header.Set(...)` will panic. Handle the error and return 
early instead of discarding it.
   
   This issue also appears in the following locations of the same file:
   - line 75
   - line 108



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to