Azure / Azure/azure-functions-java-worker
Optional route parameter without type is not correctly parsed
- Dominant language
- Java
- Stars
- 103
- Forks
- 74
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 2
Description
#### Investigative information
- Timestamp: 2019-05-26 05:43:59.033 UTC
- Invocation ID: 90a11823-2911-41aa-969c-f228f75865a0
- Region: France Central
#### Repro steps
*This behavior is only reproductible when the function app is executed on Azure, and it does not appear when running locally*
Run an Http triggered Function App which contains an optional route parameter without type specified with it, as for example : https://example.azurewebsites.net/api/functionname/{parameter?}.
By parameter with type I mean a parameter like {parameter:type} which is not used here.
#### Expected behavior
The expected behavior would be to get the actual value provided for the parameter.
#### Actual behavior
The optional parameter without type is not parsed correctly:
- if the function is executed without a value specified for this parameter, it ends with a NullPointerException :
`Result: Failure
Exception: NullPointerException:
Stack: java.lang.NullPointerException
at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:54)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:62)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:42)
at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:52)
at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:51)
at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
`
- if a value is given to this parameter in the triggering URL, the parameter is incorrectly parsed and the returned value is the name of the parameter until the question mark.
E.g. with the example URL I gave before, if we call :
-- https://example.azurewebsites.net/api/functionname : the NPE is thrown ;
-- https://example.azurewebsites.net/api/functionname/avalue : instead of the value, I got "{parameter".
#### Known workarounds
Optional parameters with a type (e.g. "{parameter:alpha?}") cannot be obtained with the annotation `@BindingName` as it also returns a NPE, but it is nevertheless possible to retrieve their values by parsing the URL with `request.getUri().getPath()`.
Non-optional parameters, that is, without a question mark, work fine.
#### Related information
* Programming language used = Java 8
* Bindings used = http binding
Contributor guide
Assessment
This issue has not been assessed yet.