SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

mongo-uri env variable escaped leads to error #327

Closed boof1977 closed 5 years ago

boof1977 commented 5 years ago

setting in dev.properties the following variable

mongouri = mongodb://127.0.0.1/?readPreference=primary&authSource=admin

leads to RESTHeart not starting with following error message

Caused by: java.lang.IllegalArgumentException: The connection string contains an invalid option 'readPreference=primary&authSource=admin'. 'readPreference' is missing the value delimiter eg 'readPreference=value'

Expected Behavior

daemon service should be start.

Current Behavior

we are getting an error: wrong parameter mongo-uri the connection string contains an invalid option 'authSource=...'

Context

we can not connect to mongo version 4 .

Environment

RH 3.6 mongodb 4

Steps to Reproduce

  1. set in dev.properties the following variable mongouri = mongodb://127.0.0.1/?readPreference=primary&authSource=admin
  2. java -jar target/restheart.jar etc/restheart.yml -e etc/dev.properties

Possible Implementation

The problem seems to be related to the new env file. If the same mongo-uri is set directly in the xml conf file it works as expected. The problem seems that resolving the variable leads to replace the char = with =

ujibang commented 5 years ago

in the yml configuration file the properties are defined as {{mongouri}}

however with mustache.java (used to replaced variables)

Outputting data with {{data}} (double mustache) always escapes html characters. Use {{{data}}} (triple mustache) if you don't want it escaped.

we just need to define vars as {{{mongouri}}}

ujibang commented 5 years ago

fixed in 0c0f0f510ad669594074988057e812d3e56c5aa4

mkjsix commented 5 years ago

@boof1977 we'll release a patch in RESTHeart version 3.6.3 (within a few hours), thank you and sorry for the inconvenience.

mkjsix commented 5 years ago

@boof1977 we have just released RESTHeart version 3.7.0 which fixes this issue.

Please let us know in case of problems.