nuagenetworks/go-bambou

Under rare circumstances subsequent request has an empty body

Opened this issue · 2 comments

This regression was introduce by fixing #10. It seems that Requestobject in Go should not be reused when Request contains a Body.
I am proposing to create a new Request object for the subsequent request when entering the Multiple Choices case. The difference with the original version (before #10) will be to use the GetBody function to get a copy of the Body to create the new Request.

I will be opening a PR to fix this.

hellt commented

I am hitting this issue with 100% probability when trying to create a static route. Here is the log that shows that the subsequent requests body is indeed empty in the multiple choise case:

DEBU[0001] Request Method URL: POST https://124.252.253.84:8443/nuage/api/v5_0/domains/c651ef53-5b52-46b9-86f7-856f796b5741/staticroutes 
DEBU[0001] Request Headers: map[Authorization:[XREST YWRtaW46ZTQzYzJkZTktMDQxNi00ZDcxLThkNjItOGNhZDRlZWMxODAz] Content-Type:[application/json] X-Nuage-Organization:[csp] X-Nuage-Pagesize:[50]] 
DEBU[0001] Request Payload: {{"BFDEnabled":false,"address":"1.1.1.0","netmask":"255.255.255.0","nextHopIp":"10.10.10.1"}
} 
DEBU[0001] Response Status: 300 Multiple Choices        
DEBU[0001] Response Headers: map[Access-Control-Allow-Origin:[*] Access-Control-Expose-Headers:[X-Nuage-Organization, X-Nuage-ProxyUser, X-Nuage-OrderBy, X-Nuage-FilterType, X-Nuage-Filter, X-Nuage-Page, X-Nuage-PageSize, X-Nuage-Count, X-Nuage-Custom, X-Nuage-ClientType, X-SSL-Client-CN, X-SSL-Client-ORG, X-SSL-Client-UID, X-SSL-Issuer-CN, X-SSL-Client-DN, X-SSL-Issuer-DN] Content-Length:[268] Content-Security-Policy:[default-src] Content-Type:[application/json] Date:[Thu, 19 Sep 2019 11:49:39 GMT] Referrer-Policy:[origin] Server:[Apache-Coyote/1.1] Set-Cookie:[rememberMe=deleteMe; Path=/nuage; Max-Age=0; Expires=Wed, 18-Sep-2019 11:49:39 GMT] Strict-Transport-Security:[max-age=31536000] X-Content-Type-Options:[nosniff] X-Frame-Options:[deny] X-Nuage-Request-Id:[897caef8-9cb4-4171-9993-1f75d5371c35] X-Xss-Protection:[1]] 
DEBU[0001] Request Method URL: POST https://124.252.253.84:8443/nuage/api/v5_0/domains/c651ef53-5b52-46b9-86f7-856f796b5741/staticroutes?responseChoice=1 
DEBU[0001] Request Headers: map[Authorization:[XREST YWRtaW46ZTQzYzJkZTktMDQxNi00ZDcxLThkNjItOGNhZDRlZWMxODAz] Content-Type:[application/json] X-Nuage-Organization:[csp] X-Nuage-Pagesize:[50]] 
DEBU[0001] Request Payload: {}                          
2019/09/19 14:49:40 {"title": "HTTP client error", "description": "Post https://124.252.253.84:8443/nuage/api/v5_0/domains/c651ef53-5b52-46b9-86f7-856f796b5741/staticroutes?responseChoice=1: http: ContentLength=92 with Body length 0"}

Basically this makes the library to contain a serious blocker which reproduces with every multiple choice POST/PUT object.

@pdellaert will it be possible to address this one and merge the #13, if @rvichery confirms that its not WIP anymore

#13 seemed to fix the issue but it was introducing other problems if I recall correctly. It will be good to verify this fix carefully.