'fastapi 0.73.0 issue : TypeError: '<' not supported

My code is working fine for fastapi==0.72.0. But for fastapi==0.73.0, its throws the below error.

TypeError: '<' not supported between instances of 'NoneType' and 'int'

Rest, there is no change in the code for the 2 versions.

It breaking at call_next response(its endpoint_function in my case)

#middleware added
@project.middleware("http")
async def request_check(request:Request,endpoint_function):
   token=request.headers.get("token")
   request_url=request["path"]
   url_4th=str(request.url).split("/")[3]
   #public endpoint check
   if url_4th=="public" or url_4th=="":
      response=await endpoint_function(request)
      return response


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source