sdk-generator icon indicating copy to clipboard operation
sdk-generator copied to clipboard

fix(dotnet-sdk): Fix broken rate limit handling

Open Hawxy opened this issue 11 months ago • 4 comments

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

Hawxy avatar Feb 17 '25 08:02 Hawxy

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

rhamzeh avatar Feb 18 '25 16:02 rhamzeh

@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.

rhamzeh avatar Feb 27 '25 20:02 rhamzeh

Yep that looks good.

Hawxy avatar Feb 28 '25 01:02 Hawxy