Skip to content
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

Timer Trigger arg_name cannot use snake case #9917

Closed
williamhbell opened this issue Feb 19, 2024 · 6 comments · Fixed by #10764
Closed

Timer Trigger arg_name cannot use snake case #9917

williamhbell opened this issue Feb 19, 2024 · 6 comments · Fixed by #10764

Comments

@williamhbell
Copy link

Investigative information

func --version
4.0.5530

Repro steps

Provide the steps required to reproduce the problem:
  • Create a new Azure function
func new --template "Timer Trigger" --name another_trigger
  • Change the generated code from
@app.timer_trigger(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=True,
              use_monitor=False) 
def another_trigger(myTimer: func.TimerRequest) -> None:

to

@app.timer_trigger(schedule="0 */5 * * * *", arg_name="my_timer", run_on_startup=True,
              use_monitor=False) 
def another_trigger(my_timer: func.TimerRequest) -> None:
  • Run the function, which results in an error of the form:
The 'another_trigger' function is in error: The binding name my_timer is invalid. Please assign a valid name to the binding.

Expected behaviour

It should be possible to use a binding name that uses snake case, since this is the normal convention for Python programs.

Actual behaviour

The 'another_trigger' function is in error: The binding name my_timer is invalid. Please assign a valid name to the binding.

Known workarounds

Remove the _ character from the binding and variable name.

Contents of the requirements.txt file:

azure-functions==1.18.0
@bhagyshricompany bhagyshricompany self-assigned this Feb 23, 2024
@bhagyshricompany
Copy link

Thanks for reporting will check and update.Thanks

@bhagyshricompany
Copy link

Hi @williamhbell pls have a look this is not supported.Azure/azure-functions-python-worker#1174

@williamhbell
Copy link
Author

@bhagyshricompany thanks for spotting Azure/azure-functions-python-worker#1174. It appears to be the same bug. As mentioned in Azure/azure-functions-python-worker#1174, snake case is normally used for Python variables following PEP8 https://peps.python.org/pep-0008/#function-and-variable-names .

@bhagyshricompany
Copy link

yes but right now not have support.

@YunchuWang YunchuWang self-assigned this Mar 4, 2024
@YunchuWang
Copy link
Member

the validation is done in azure functions host at

private static readonly Regex BindingNameValidationRegex = new Regex(string.Format("^([a-zA-Z][a-zA-Z0-9]{{0,127}}|{0})$", Regex.Escape(ScriptConstants.SystemReturnParameterBindingName)));
.

@YunchuWang
Copy link
Member

Transferring to Azure Function Host to continue the discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants