-
Notifications
You must be signed in to change notification settings - Fork 454
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
C# runtime can break based on parameter name #46
Comments
Yes, currently he's matching parameters in metadata to those in code via name. Only an issue for C#. When you don't explicitly name your param in function.json it defaults to 'input'. If you added name: 'req' to your binding it would work. This is just a loose end. C# parameter matching should probably be positional. For all other language types other than C# it makes sense to specify names in config, but for C# the names come from the code. I had this on my list to go look into / fix after the C# review. |
I see. That feels a little too magical :) And the lack of error handling made it super hard to diagnose. Note that our template is broken out of the box: https://github.com/Azure/azure-webjobs-sdk-templates/tree/master/Templates/HttpTrigger-CSharp (I'll fix it). |
I don't think it's broken - the default will be 'input' in metadata and that matches. The same one in this repo samples works as is as well. |
Only because I just fixed it :) |
👍 |
@fabiocav: why does that break at runtime, but not at compile time in the designer? That would help catch this more easily. e.g. "your function must have an |
Yes, we could turn this into a compile time error, which would lead to a much better experience. I'd like to chat with @mathewc to get some of his ideas. I have concerns about making it positional, but not having a parameter (e.g. "input") should be ok. If I don't need to actually consume that input, I could omit it. The issue would be the other way around, where I have parameters we wouldn't know how to populate at runtime. But the argument parameters from the bindings (in addition to the bindings themselves) would play a role there as well. |
My take is that with good error handling, there is no need to make it positional. We could make it very clear what's wrong, by looking at both what they declared and what we have available. In the case above, the message could be:
|
Yes it would be good if we don't have to treat C# specially in this regard. It does seem strange to me that you'll have to name your parameters both in metadata, and in code, and keep them in sync. However maybe that's the safest way of associating metadata. |
The following function runs fine:
Now replace
HttpRequestMessage input
withHttpRequestMessage req
, and it blows up at runtime with a generic 500 error.So really two issues:
The text was updated successfully, but these errors were encountered: