Skip to content

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

Closed
@atimgraves

Description

@atimgraves

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions