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

property value for '__initialmatch__' not getting set #165

Closed
Kaushalop opened this issue Sep 6, 2016 · 2 comments
Closed

property value for '__initialmatch__' not getting set #165

Kaushalop opened this issue Sep 6, 2016 · 2 comments

Comments

@Kaushalop
Copy link

I have been trying to use the json-server example for Rivescript but getting the error:

Cannot set property 'initialmatch' of undefined

Any reasons why this could occur?

@kirsle
Copy link
Member

kirsle commented Sep 6, 2016

What were you doing that caused this bug? If used correctly (e.g. sending a JSON payload to the server) I can't reproduce it normally (even if I forget the "username" or "message" parameters from the payload).

A reliable way I found to reproduce the bug:

  1. Start the json server
  2. Send a blank JSON object to it, like this:
curl -i \
   -H "Content-Type: application/json" \
   -X POST -d '{}' \                                               
   http://localhost:2001/reply

The server needs the "username" and "message" parameters from the client. If you just go to http://localhost:2001/ in your browser, it gives you a curl command you can copy and paste to test it:

Usage: curl -i \
   -H "Content-Type: application/json" \
   -X POST -d '{"username":"soandso","message":"Hello bot","vars":{"name":"Soandso"}}' \
   http://localhost:2001/reply

I'll update the json-server example to make it a little more 'bulletproof', but bear in mind the example codes are just that, examples; I wouldn't recommend using any of them as-is for production use with many users (for example the json-server does no garbage collection of user variables on its own, so if you threw thousands/millions of distinct usernames at it, it wouldn't scale very well).

@kirsle kirsle closed this as completed in 8e3d97b Sep 6, 2016
@Kaushalop
Copy link
Author

It was primarily showing up because the user array was not getting initialised so i fixed the POJO Class that was handling it. Thanks for the help

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