-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Checklist
- I have looked into the README and have not found a suitable solution or answer.
- I have looked into the documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have upgraded to the latest version of OpenFGA and the issue still persists.
- I have searched the Slack community and have not found a suitable solution or answer.
- I agree to the terms within the OpenFGA Code of Conduct.
Description
Hi! I've noticed some errors with the Go SDK that doesn't seem to retry failing requests when the server returns 5xx responses. I wrote this small test to reproduce:
package openfga_test
import (
"net/http"
"net/http/httptest"
"testing"
fga_sdk "github.com/openfga/go-sdk"
)
func TestRetryParams(t *testing.T) {
requestCount := 0
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
requestCount++
http.Error(w, "test error", http.StatusServiceUnavailable)
}))
defer server.Close()
api := fga_sdk.NewAPIClient(&fga_sdk.Configuration{
ApiUrl: server.URL,
RetryParams: &fga_sdk.RetryParams{
MaxRetry: 5,
MinWaitInMs: 100,
},
}).OpenFgaApi
api.Check(t.Context(), "some-store-id").Body(fga_sdk.CheckRequest{
TupleKey: fga_sdk.CheckRequestTupleKey{
User: "user:some-user-id",
Relation: "some-relation",
Object: "object:some-object-id",
},
}).Execute()
if requestCount < 2 {
t.Fatalf("Expected at least 2 retries, got %d", requestCount)
}
}
Which errors with:
Expected at least 2 retries, got 1
By looking through the code, it seems that the issue is here:
Line 600 in 387aa77
if !e.shouldRetry { |
The function looks at e.shouldRetry
, but I don't see the field's value ever being set to true
.
The logic implemented just above in the exported ShouldRetry()
func seems like what should be invoked instead:
Line 594 in 387aa77
func (e FgaApiInternalError) ShouldRetry() bool { |
Expectation
see description
Reproduction
See description
OpenFGA SDK version
0.7.1
OpenFGA version
1.8.6
SDK Configuration
see description
Logs
No response
References
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done