Problem
Nested if statement that checks for StatusCode == 200 is always ignored:
if localVarHttpResponse.StatusCode < 300 {
// If we succeed, return the data, otherwise pass on to decode error.
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if err == nil {
return localVarReturnValue, localVarHttpResponse, err
}
}
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericSwaggerError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
//the issue is here
if localVarHttpResponse.StatusCode == 200 {
var v V1beta1BatchCreateNotesResponse
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
return localVarReturnValue, localVarHttpResponse, newErr
}
This code checks if the StatusCode value is more than 300, and, if it is true, it checks if the StatusCode is equal to 200, which means that this nested if statement will never be true.
I did not observe any issues happening because of this problem because if StatusCode == 200 the if statement above (if localVarHttpResponse.StatusCode < 300 ) will be executed.
This problem reoccurs for every function in api_grafeas_v1_beta1.go that expects a response.
Potential Solution
Move StatusCode == 200 if statement inside of if localVarHttpResponse.StatusCode < 300 {} or before it, e.g.:
if localVarHttpResponse.StatusCode < 300 {
// If we succeed, return the data, otherwise pass on to decode error.
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
if localVarHttpResponse.StatusCode == 200 {
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = localVarReturnValue
return localVarReturnValue, localVarHttpResponse, newErr
}
if err == nil {
return localVarReturnValue, localVarHttpResponse, err
}
}
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericSwaggerError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
return localVarReturnValue, localVarHttpResponse, newErr
}
Problem
Nested if statement that checks for
StatusCode == 200is always ignored:This code checks if the
StatusCodevalue is more than 300, and, if it is true, it checks if theStatusCodeis equal to 200, which means that this nested if statement will never be true.I did not observe any issues happening because of this problem because if
StatusCode == 200the if statement above (if localVarHttpResponse.StatusCode < 300) will be executed.This problem reoccurs for every function in
api_grafeas_v1_beta1.gothat expects a response.Potential Solution
Move
StatusCode == 200if statement inside ofif localVarHttpResponse.StatusCode < 300 {}or before it, e.g.: