actions-on-google / actions-on-google-testing-nodejs

Apache License 2.0
75 stars 18 forks source link

Bug in .startWith() #24

Closed joecaine closed 6 years ago

joecaine commented 6 years ago

Hi there,

Was trying this package out today and ran into this error when using .startWith(). I know that the method successfully hit my action, but it threw the following error:

Uncaught Exception TypeError: Cannot read property 'url' of undefined actionResponse.items.forEach (node_modules/actions-on-google-testing/src/actions-on-google.ts:477:76) ClientDuplexStream.conversation.on (node_modules/actions-on-google-testing/src/actions-on-google.ts:425:42) Object.onReceiveMessage (node_modules/grpc/src/client_interceptors.js:1276:19) InterceptingListener.recvMessageWithContext (node_modules/grpc/src/client_interceptors.js:603:19) node_modules/grpc/src/client_interceptors.js:702:14

Fleker commented 6 years ago

Looks like the error throws here:

} else if (i.mediaResponse) {
    assistResponse.mediaResponse = {
      type: i.mediaResponse.mediaType,
      name: i.mediaResponse.mediaObjects[0].name,
      description: i.mediaResponse.mediaObjects[0].description,
      sourceUrl: i.mediaResponse.mediaObjects[0].contentUrl,
      icon: i.mediaResponse.mediaObjects[0].icon.url,
    }
} 

Are you returning a media response? Can you pull the content? It may be throwing because this library assumes that an icon is available, although that may not be the case and we may need to fix that.

yoichiro commented 6 years ago

@Fleker In the specification of the MediaObject structure, each MediaObject can have only one of icon or largeImage. It is possible that a MediaObject doesn't have the icon. That is, joecaine might had specified the largeImage. The current code of the latest version expects that the icon is specified. I guess that we need to fix the code so that both icon and largeImage can be specified.

I intend to confirm whether the thinking above is right or not, and if can confirm I will create a pull request to fix this issue.

joecaine commented 6 years ago

Thanks for quick response. I hadn't actually specified either a largeImage or an icon. In the prototype I'd built I'd got it to run on a device just specifying a url.

yoichiro commented 6 years ago

@Fleker My pull request was merged into the master branch. This is a bug. I think that we should release a new version including the fix code for this issue soon.

Fleker commented 6 years ago

Fixed in v0.2.2