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

NullReferenceException when Content-type unspecified. #36

Closed
AKomyshan opened this issue Feb 1, 2019 · 1 comment
Closed

NullReferenceException when Content-type unspecified. #36

AKomyshan opened this issue Feb 1, 2019 · 1 comment

Comments

@AKomyshan
Copy link
Contributor

AKomyshan commented Feb 1, 2019

For reproduce this error you simply can run Getting started example.

In current version we must set Content-type for all requests, but in case of GET methods when we produce request from browser Content-type are not added to headers request.

I have research the HTTP Protocol specification and googling should we set Content-type for all requests and TL;DR: Get requests should not have content-type because they do not have request entity (that is, a body)

I suggest to make the Content-type is not required. (At least for GET requests)

Repro steps:

  1. Run https://functionmonkey.azurefromthetrenches.com/guides/gettingStarted.html this guide.
  2. Run HelloWorld function from browser.

Error example:

` Http Functions:

    HelloWorldProxy: [GET] http://localhost:7071/api/v1/HelloWorld

    HelloWorld: [GET] http://localhost:7071/api/HelloWorld

[01.02.2019 11:01:10] Executing HTTP request: {
[01.02.2019 11:01:10]   "requestId": "db8c0b57-3857-4c51-b99b-778140cf5f63",
[01.02.2019 11:01:10]   "method": "GET",
[01.02.2019 11:01:10]   "uri": "/api/v1/HelloWorld"
[01.02.2019 11:01:10] }
[01.02.2019 11:01:11] Executing 'Functions.HelloWorldProxy' (Reason='This function was programmatically called via the host APIs.', Id=796ca58c-035e-41ee-ad26-ae9464a70c2c)
[01.02.2019 11:01:11] Host lock lease acquired by instance ID '00000000000000000000000011CD3113'.
[01.02.2019 11:01:11] Executing request via Azure Function Proxies
[01.02.2019 11:01:11] Executing 'HelloWorld' (Reason='This function was programmatically called via the host APIs.', Id=7e582cfa-c725-4dc0-933b-4b742d30ac1b)
[01.02.2019 11:01:12] HTTP trigger function HelloWorld processed a request.
[01.02.2019 11:01:16] Executed 'HelloWorld' (Failed, Id=7e582cfa-c725-4dc0-933b-4b742d30ac1b)

[01.02.2019 11:01:16] System.Private.CoreLib: Exception while executing function: HelloWorld. TestNRE.Functions.dll: Object reference not set to an instance of an object.

[01.02.2019 11:01:16] Executed 'Functions.HelloWorldProxy' (Succeeded, Id=796ca58c-035e-41ee-ad26-ae9464a70c2c)
[01.02.2019 11:01:17] Executed HTTP request: {
[01.02.2019 11:01:17]   "requestId": "db8c0b57-3857-4c51-b99b-778140cf5f63",
[01.02.2019 11:01:17]   "method": "GET",
[01.02.2019 11:01:17]   "uri": "/api/v1/HelloWorld",
[01.02.2019 11:01:17]   "identities": [
[01.02.2019 11:01:17]     {
[01.02.2019 11:01:17]       "type": "WebJobsAuthLevel",
[01.02.2019 11:01:17]       "level": "Admin"
[01.02.2019 11:01:17]     }
[01.02.2019 11:01:17]   ],
[01.02.2019 11:01:17]   "status": 500,
[01.02.2019 11:01:17]   "duration": 6194
[01.02.2019 11:01:17] }`

Error reason:

Looks like trouble in http.csharp.handlebars file in line
string contentType = req.ContentType.ToLower();

UPD: I can suggest a PR to fix this bug, but I don't have permissions to push.

@JamesRandall
Copy link
Owner

Thanks for reporting this in such a clear way - super appreciated.

I happened to be in the code resolving a Swagger issue so have made this fix while there. Should be in FunctionMonkey.Compiler 0.19.3.

Thank you!

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

No branches or pull requests

2 participants