fix(dotnet-sdk): Fix broken rate limit handling
Description
This unhelpfully deadlocked my test pipeline today. This code hasn't been touched for 3 years and has always been broken as far as I can tell. The tests also made the incorrect assumption about the header shape.
In the test suite, change the header configuration to:
response.Headers.Add(RateLimitParser.RateLimitHeader.LimitResetIn, DateTimeOffset.UtcNow.AddSeconds(10).ToUnixTimeSeconds().ToString());
And the assertion to:
Assert.InRange(error.ResetInMs!.Value, 0, 10000);
References
Closes https://github.com/openfga/dotnet-sdk/issues/76
Review Checklist
- [x] I have clicked on "allow edits by maintainers".
- [x] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
- [x] The correct base branch is being used, if not
main - [x] I have added tests to validate that the change in functionality is working as expected
Thanks @Hawxy!
If you don't mind - will do some changes to your PR as we want to move from supporting these old headers to supporting the standard Retry-After header.
Related issues:
- https://github.com/openfga/sdk-generator/issues/495
@Hawxy will work on the tests after - but would do you forsee any problems in this follow up change on top of yours? https://github.com/openfga/sdk-generator/compare/main...fix/rate-limit
If yes, and after fixing the tests - still need to resolve a few issues in https://github.com/openfga/dotnet-sdk/pull/92 resolved and backported before we merge this.
Yep that looks good.