- 
                Notifications
    
You must be signed in to change notification settings  - Fork 107
 
Open
Description
Expected Behavior
Proper error or header ignored when request header 'x-forwarded-port' is not an integer (string for example).
Actual Behavior
500 error
Steps to Reproduce
- Use 
await AsgiMiddleware(app).handle_async(req, context) - Make a request with headers['x-forwarded-port']="xxx"
 ValueError: invalid literal for int() with base 10: 'xxx'=> 500 error
Relevant code being tried
Relevant log output
Traceback (most recent call last):
  File "/home/site/wwwroot/function_app.py", line 228, in http_trigger
    return await AsgiMiddleware(fastapi_app).handle_async(req, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/azure-functions-host/workers/python/3.11/LINUX/X64/azure/functions/_http_asgi.py", line 209, in handle_async
    return await self._handle_async(req, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/azure-functions-host/workers/python/3.11/LINUX/X64/azure/functions/_http_asgi.py", line 212, in _handle_async
    asgi_request = AsgiRequest(req, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/azure-functions-host/workers/python/3.11/LINUX/X64/azure/functions/_http_asgi.py", line 28, in __init__
    super().__init__(func_req, func_ctx)
  File "/azure-functions-host/workers/python/3.11/LINUX/X64/azure/functions/_http_wsgi.py", line 44, in __init__
    self.server_port = str(self._get_port(url, self._lowercased_headers))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/azure-functions-host/workers/python/3.11/LINUX/X64/azure/functions/_http_wsgi.py", line 116, in _get_port
    return int(lowercased_headers['x-forwarded-port'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '90344081.test.com'requirements.txt file
Where are you facing this problem?
Local - Core Tools
Function app name
No response
Additional Information
No response
mabeshark