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

Problem with Java FDK, when there is no input for JSON example #32

Closed
atimgraves opened this issue Nov 26, 2018 · 2 comments
Closed

Problem with Java FDK, when there is no input for JSON example #32

atimgraves opened this issue Nov 26, 2018 · 2 comments
Assignees
Labels

Comments

@atimgraves
Copy link

The Java FDK tutorial http://fnproject.io/tutorials/JavaFDKIntroduction/ goes through various steps. Towards the end of the tutorial it covers how to use JSON input.
Once you've got the JSON input se-up (main and test classes updated as per the tutorial) it tells you to tun the following command to test the new function
curl -H "Content-Type: application/json" http://localhost:8080/t/java-app/javafn-trigger
The tutorial says you should get the following response
{"salutation":"Hello World"}
But you actually get
{"message":"invalid function response"}
and the fn server outputs
time="2018-11-26T18:34:16Z" level=info msg="starting call" action="server.handleHTTPTriggerCall)-fm" appName=java-app app_id=01CX8KWVCKNG8G00GZJ0000001 container_id=01CX8MSK6DNG8G00GZJ0000002 fn_id=01CX8KWVCTNG8G00GZJ0000002 id=01CX8MSX0VNG8G00GZJ0000004 triggerSource=/javafn-trigger
time="2018-11-26T18:34:17Z" level=info msg="hot function terminating" app_id=01CX8KWVCKNG8G00GZJ0000001 cpus= error="FDK Error, invalid status code 500" fn_id=01CX8KWVCTNG8G00GZJ0000002 id=01CX8MSK6DNG8G00GZJ0000002 idle_timeout=30 image="fndemouser/javafn:0.0.3" memory=128
time="2018-11-26T18:34:17Z" level=error msg="api error" action="server.handleHTTPTriggerCall)-fm" appName=java-app code=502 error="invalid function response" triggerSource=/javafn-trigger

Doing this with input generates the expected response
curl -H "Content-Type: application/json" http://localhost:8080/t/java-app/javafn-trigger
{"message":"invalid function response"}
[fn@fn javafn]$ curl -H "Content-Type: application/json" -d '{"name":"Bob"}' http://localhost:8080/t/java-app/javafn-trigger
{"salutation":"Hello Bob"}[fn@fn javafn]$

I tried a bit of test code to see if the function was getting called (testing for the input being null) but it errors before it gets to that point

Either the tutorial is wrong and you shouldn't be able to call this with no input (looking at the json version of the code it doesn't check for no input) or there is a problem in the fdk runtime with processing the situation with no input

@michael-w-williams
Copy link
Member

Let me take a look. It seems like this might be something we are waiting on a fix for.

@michael-w-williams
Copy link
Member

This issue is covered by this FDK-Java issue: fnproject/fdk-java#148. Will add a note to the tutorial pointing to the issue.

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

No branches or pull requests

2 participants