Code Monkey home page Code Monkey logo

Comments (8)

laurentS avatar laurentS commented on May 21, 2024 1

I've been able to reproduce the issue in a test, but haven't had time to put together a complete fix. I'm not far off, I'll try to finish it over the weekend.

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

Further investigation it seems the issue only appears when using a custom method to return the limit, but does not happen when using a string.

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

The custom method to return a rate limit is simply:

def get_user_rate_limit() -> str:
    return "100/1 day"

So nothing fancy there. If I simply use a string on the limit decorator everything works as I would expect.

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

anyone else experiencing this issue?

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

@laurentS still happening for me

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

@laurentS Did you manage to get a fix for this?

Its causing some weird behaviour around the slowapi/extension.__limit_decorator:async_wrapper where the second request comes through as None throwing:

  File "D:\programming\financefeast_api\venv\lib\site-packages\slowapi\extension.py", line 622, in async_wrapper
    raise Exception(
Exception: parameter `request` must be an instance of starlette.requests.Request

from slowapi.

laurentS avatar laurentS commented on May 21, 2024

@papapumpnz no, sorry. I haven't found time to work on this any further. It would probably help if you could provide a couple of test cases that reproduce the error(s) you see (and the cases where you don't see an error).

from slowapi.

papapumpnz avatar papapumpnz commented on May 21, 2024

Ok @laurentS forked and have a new test suite called test_double_headers that produces double headers, or single headers. Difference is the limiter decorator uses either a callable (produces double headers) or a string (produces single headers).

from slowapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.