0

I am using janusgraph with cassandra as storage backend. I am using a node package called as bcrypt to encrypt a password before saving it. The data type for that property in janusgraph is String. This is the password hash string which got generated - $2a$10$JSR6FClewTOHGxwpt/F0AePRzGnKvV2L9gj4TL1dA9fQERLWrig7u

This is the error I am getting while trying to save it in the db:

"message": "startup failed:\nScript88.groovy: 1: illegal string body character after dollar sign;\n   solution: either escape a literal dollar sign \"\\$5\" or bracket the value expression \"${5}\" @ line 1, column 228.\n   elf_reg_ind\",\"2\",\"self_reg_pw\",\"$2a$10$J\n                                 ^\n\n1 error\n",
  "Exception-Class": "org.codehaus.groovy.control.MultipleCompilationErrorsException"

Please let me know if you need any other info.

Vipul Sharma
  • 768
  • 3
  • 11
  • 25

2 Answers2

1

The query you are passing to the server gets compiled with Groovy, and Groovy is attempting to resolve the $ as an identifier. You have a literal $ in your hash, so you need to put a \ in front of each $ to escape it. For example:

{ "gremlin":
    "g.V(1234).property('hash', '\$2a\$10\$JSR6FClewTOHGxwpt/F0AePRzGnKvV2L9gj4TL1dA9fQERLWrig7u')"
}
Jason Plurad
  • 6,682
  • 2
  • 18
  • 37
0

Not a groovy guru myself, but I realised this evaluation is only attempted when using double quotes so I managed to solve this issue by ensuring that I use single quotes. I'm using PHP so the process is to first json_encode then interchange double quotes for single quotes taking care of any already escaped quotes (if any) in between.

Don Omondi
  • 946
  • 9
  • 15