yokawasa / azure-functions-python-samples

Azure Functions Python Sample Codes. NOTE: The project, hosted in a repository, is no longer actively maintained by its creators or contributors. There won't be any further updates, bug fixes, or support from the original developers in the project.
MIT License
392 stars 181 forks source link

Function returns a 500 server error, function log says req_body being accessed before it is set #24

Closed norton287 closed 5 years ago

norton287 commented 5 years ago

Successfully deployed the http trigger sas token generator to azure but when I test it using the azure test utility the console gives the following error.

2019-06-07T12:11:57.118 [Information] Executing 'Functions.GLNorton287Func' (Reason='This function was programmatically called via the host APIs.', Id=00cf0c14-75be-4070-b48e-292dfcefd3ae)
2019-06-07T12:11:57.222 [Information] Python HTTP trigger function processed a request.
2019-06-07T12:11:57.251 [Information] Executed 'Functions.GLNorton287Func' (Succeeded, Id=00cf0c14-75be-4070-b48e-292dfcefd3ae)ailure
Exception: UnboundLocalError: local variable 'req_body' referenced before assignment
Stack:   File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 300, in _handle__invocation_request
    self.__run_sync_func, invocation_id, fi.func, args)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 389, in __run_sync_func
    return func(**params)
  File "/home/site/wwwroot/GLNorton287Func/__init__.py", line 164, in main
    permission = req_body.get('permission')

Any ideas why this is happening?

Thank you

John

yokawasa commented 5 years ago

@norton287 Thank you for the issue. I'll verify and get back to you shortly

norton287 commented 5 years ago

@yokawasa Thanks for looking into this

yokawasa commented 5 years ago

@norton287 I add some exception handing for this. Here is diff

Please use the latest function - http-trigger-blob-sas-token and try again

norton287 commented 5 years ago

@yokawasa That worked perfect! Thank you very much!

yokawasa commented 5 years ago

@norton287 thanks for your confirmation! I’m glad to know it worked.