Skip to content

Timer trigger function results in output TypeError #1479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gijs-romme opened this issue Apr 17, 2024 · 15 comments · Fixed by #1379
Closed

Timer trigger function results in output TypeError #1479

gijs-romme opened this issue Apr 17, 2024 · 15 comments · Fixed by #1379

Comments

@gijs-romme
Copy link

gijs-romme commented Apr 17, 2024

Is your question related to a specific version? If so, please specify:

Version 2

What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)

My function has a timer input trigger and a sendgrid output trigger.

Question

Yesterday I added a new function to my Azure function app. Since adding it, an already existing function (with the bindings described above) that I didn't change anything about doesn't run correctly anymore because it gives the following error:
Result: Failure Exception: TypeError: unable to encode outgoing TypedData: unsupported type "<class 'azure_functions_worker.bindings.generic.GenericBinding'>" for Python type "NoneType"
I see online that this error occurs when your function has an HTTP output binding and you don't return any HTTPResponse. However, mine doesn't have any HTTP binding. It's not supposed to return anything as you create the output by calling the 'set' method on the 'sendGridMessage' input argument.
I already restore the function app back the its previous state by deleting the function that I added yesterday, but the error keeps on happening. Could anyone help me fix this issue please? It might also just be a bug...

Here's the function.json file content:
{ "scriptFile": "__init__.py", "bindings": [ { "name": "mytimer", "type": "timerTrigger", "direction": "in", "schedule": "0 0 * * * *" }, { "type": "sendGrid", "name": "sendGridMessage", "direction": "out", "apiKey": "SendGridAPIKey", "from": "..." } ], "retry": { "strategy": "exponentialBackoff", "maxRetryCount": 5, "minimumInterval": "00:00:10", "maximumInterval": "00:15:00" } }

And the relevant parts of my init.py file:
def main(mytimer: func.TimerRequest, sendGridMessage: func.Out[str]) -> None: # noqa: F841 message = ... sendGridMessage.set(json.dumps(message)) logging.info('Function ran successfully.')

@gavin-aguiar
Copy link
Contributor

@gijs-romme Can you try removing the return None or return just any string for your second function?
Would you also be able to share your functionapp name or any previous invocation id?

@rrr-michael-aquilina
Copy link

I'm facing a similar issue in the last couple days, code did not change but the same error started to appear on eventgrid functions

@benyahiaabdelmonem
Copy link

Hello,
I have the same issue. Errors appeard without changing any thing in the code. I still have the same error even when I modified the code in light version.
This is the main in the init.py :
def main(sqlChanges) -> None:
logging.info(sqlChanges)
And this is the binding :

{
"scriptFile": "init.py",
"bindings": [
{
"name": "sqlChanges",
"type": "sqlTrigger",
"direction": "in",
"tableName": "notif.go_nogo",
"connectionStringSetting": "SqlConnectionString"
}
]
}

Thank you for your help

@claria
Copy link

claria commented Apr 18, 2024

Same here on very different trigger types.
What worked for me as a workaround was changing the return type to "-> str" and always
return ''
instead of a plain
return / return None.

@vegarvi
Copy link

vegarvi commented Apr 18, 2024

We experience the same issue without any change in the code

@claria
Copy link

claria commented Apr 18, 2024

To give a bit more details:

We are running around 20-30 functionapps which are python based. Some of them are written in v2 style some of them in v1 style.

  • We have observed this issue always without code changes, but possibly due to redeployments
  • More and more of our v1 functionapps are getting affected and start crashing.
  • We have not yet observed the error on v2 style written function-apps
  • All of the affected functions have the typing annotation fcn_name (...) -> None :
    - Removing the typing Annotation does not help
    - Changing the typing Annotation to -> str: and include a return '' everywhere does help but is a super annoying workaround.

Please take that issue serious!

@ArmandasB
Copy link

I encountered a similar problem with an SQL trigger after deployment yesterday with an unrelated update. It appears that returning an empty string provides a workaround.

@PhilippePaulos
Copy link

Same problem with Timer triggers. Started to happen when redeploying the function app (v1) without any code changes

@gijs-romme
Copy link
Author

@gijs-romme Can you try removing the return None or return just any string for your second function? Would you also be able to share your functionapp name or any previous invocation id?

The 'return None' originally wasn't there, so that doesn't help. Just returning any string does fix the issue however! Thank you so much!

If it still helps: I'm not sure where to get the invocation ID, but I would expect it's the ID that's visible in this line in the 'Monitor' tab?
Executing 'Functions.FunctionName' (Reason='Timer fired at 2024-04-18T12:00:00.0048481+00:00', Id=4fcf8c50-92fd-4785-9427-7997455838f3)

@claria
Copy link

claria commented Apr 18, 2024

Hi,

in the meantime i removed all the added return "" statements and fixed the host version to an old version that was used a couple of days ago and this is working as well:

In Powershell:
az functionapp config set --name xxxxxxxxxxxxxx --resource-group xxxxxxxx --linux-fx-version '"DOCKER|mcr.microsoft.com/azure-functions/python:4.31.1.1-python3.9-appservice"'

The issue sounds very related to
Azure/azure-functions-durable-python#401

@gavin-aguiar
Copy link
Contributor

Apologies for this error. We have fixed this issue and are in process of releasing a new runtime version. The fix will be in runtime version 4.33.2

@gavin-aguiar gavin-aguiar pinned this issue Apr 18, 2024
@abdulniyaspm
Copy link

@gavin-aguiar Thank you for fixing this. I am also facing this issue in my time trigger based azure function(without any code change). I am trying to understand if this fix(4.33.2) will be automatically available in our runtime or do I need to make any changes on the azure function side to upgrade to 4.33.2?

@gavin-aguiar
Copy link
Contributor

@abdulniyaspm You would just need to restart your functionapp to pick up the latest runtime version.

@benyahiaabdelmonem
Copy link

@gavin-aguiar Thank you for your answer but despite restarting my functionapp I still have the old version of runtime 4.33.1.1

@gavin-aguiar
Copy link
Contributor

@benyahiaabdelmonem we have finished deploying this fix for dedicated function apps yesterday. Consumption apps are in progress. So if you have a non-consumption function app, you should be able to get the latest runtime version by restarting.

@hallvictoria hallvictoria unpinned this issue May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants