Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

[BUG] Worker indexing passes for duplicated function names #1489

Open hallvictoria opened 1 month ago

hallvictoria commented 1 month ago

Investigative information

Please provide the following:

Functions with the same defined function name can be created and deployed. This should not be supported.

Repro steps

Provide the steps required to reproduce the problem:
  1. Create a python function app
  2. Use v2 programming model and deploy function app with following function:
    @app.function_name("hello_world")
    @app.route("hello_world", methods=["GET", "POST"])
    def hello_world1(req):
        return "Hello 1" 
  3. Indexing in the worker should succeed.
  4. Deploy to Azure, Deployment should succeed, verify that function is returning response
  5. Add another function with same function_name and routelike below:
    @app.function_name("hello_world")
    @app.route("hello_world", methods=["GET", "POST"])
    def hello_world2(req):
        return "Hello 2" 
  6. Indexing in the worker should fail but it doesn't.
  7. Deploy to Azure, Deployment should fail but it doesn't, try to run the function, (Issue 1)

Expected behavior

Provide a description of the expected behavior.

Indexing in the worker should only succeed if the function names are unique. If they are not, indexing should fail and the worker should throw an error explaining that the function names are not unique.

Actual behavior

Provide a description of the actual behavior observed.

Indexing in the worker does pass and the function breaks when deployed to the portal. Eg:

  1. After deploying to the portal, refresh the list of functions multiple times, a new duplicate row keeps getting added in portal as shown below

    Image

Known workarounds

Provide a description of any known workarounds.
  1. Remove the duplicate function from code and attempt redeployment, this should succeed and fix the issue
  2. OR: change the function names to be unique
  3. For consumption plan: The container also needs to be recycled, stop and start the app or leave the app unused for at least 15 mins.