tropo/tropo-webapi-java — Issue #9: "null" literal as grammar 'concept' breaks parser
Author: wstidolph
Created: 2011-10-20 23:11:08+00:00
State: open

Minor issue - don't use groovy keywords as concepts in a grammar. Not sure it's worth trying to 'fix' but figured it might be worth recording here.

I accidentally added the string "null" as a concept in my grammar, and then when I used an out-of-vocabulary word that string was returned as the detected concept and the tropo parser failed on the JSON returned from tropo; here I'll cut together my code and the log output to show the effect:

// my response-processing TropoController code
def tropoContinueIn={ // endpoint for 'continue' event
def json = request.JSON
log.info("tropoContinueIn concept <= " + json.result.actions?.concept) // LINE 69

//==== LOG OUTPUT ===
TropoController - tropoContinueIn concept <= null
//==== END LOG OUTPUT ===

// controller code
log.info("tropoContinueIn <= " + json) // line 70

//==== LOG OUTPUT ===

TropoController - tropoContinueIn concept <= null
TropoController - tropoContinueIn <= [result:[error:null, complete:true, sessionId:bdfa47c7bccb0f490b370d42ad00ae79, sequence:3, state:ANSWERED, sessionDuration:24, callId:3ee38a01271db2c013f87d0d5eadb159, actions:[concept:null, attempts:1, name:selectAudio_chooseAudioAction, value:null, utterance:null, xml:

null

, confidence:51, interpretation:null, disposition:SUCCESS]]]
//==== END LOG OUTPUT ===// NOTE: I had spoken and out-of-vocab response, the word 'both'

// next line in controller code
def builder = getBuilderNextAction(json,'continue') // line 71
...

private
def getBuilderNextAction(def jsonObj, def event){
Tropo tropo = new Tropo()
TropoResult result = tropo.parse(jsonObj.toString()) // line 123

//==== LOG OUTPUT ===
GrailsExceptionResolver - NoSuchMethodException occurred when processing request: [POST] /qdjoint/tropo/tropoContinueIn
Unknown property 'concept' on class 'class java.util.ArrayList'. Stacktrace follows:
java.lang.NoSuchMethodException: Unknown property 'concept' on class 'class java.util.ArrayList'
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2133)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:890)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy._setProperty(PropertySetStrategy.java:67)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy.setProperty(PropertySetStrategy.java:60)
at net.sf.json.JSONObject.setProperty(JSONObject.java:1394)
at net.sf.json.JSONObject.toBean(JSONObject.java:453)
at net.sf.json.JSONObject.toBean(JSONObject.java:406)
at net.sf.json.JSONObject.toBean(JSONObject.java:233)
at com.voxeo.tropo.TropoParser.parse(TropoParser.java:84)
at com.voxeo.tropo.Tropo.parse(Tropo.java:237)
at TropoController$$ENDuYvhA.getBuilderNextAction(TropoController.groovy:123)
at TropoController$_closure2$$ENDuYvhA.doCall(TropoController.groovy:71)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)