loopback
loopback copied to clipboard
Error: Password contains an illegal unescaped character: using loopback-connector-mongodb: ^5.5.0
Steps to reproduce
The solution stated in PR#529 does not seem to work for me.
Here is my config. Noticed the last char in password was and equal sign "=" I encoded this with %3D but I am still getting error. What am i doing wrong? Can someone help me figure it out please?
So userid and password are pre-generated by mongo-atlas on azure.
const config = {
name: 'backendDB',
connector: 'mongodb',
url: "mongodb+srv://aef38798-4404-4864-93ce-a742deee9833:oN4GmVQ96CsEIBzcPbcEeYU4V74D5-7V7V1tqSBt0v4%[email protected]/default",
useNewUrlParser: true
};
"dependencies": { "@loopback/boot": "^3.2.1", "@loopback/core": "^2.14.1", "@loopback/repository": "^3.4.1", "@loopback/rest": "^9.1.3", "@loopback/rest-explorer": "^3.1.0", "@loopback/service-proxy": "^3.0.7", "cfenv": "^1.2.4", "loopback-connector-mongodb": "^5.5.0", "tslib": "^2.0.0" }, "devDependencies": { "@loopback/build": "^6.2.9", "@loopback/eslint-config": "^10.0.5", "@loopback/testlab": "^3.2.12", "@types/node": "^10.17.51", "eslint": "^7.18.0", "source-map-support": "^0.5.19", "typescript": "~4.1.3" }
## Current Behavior
error received during cf push -f manifest.yml (see manifest below)
2021-04-12T12:40:38.04-0400 [CELL/0] OUT Downloaded droplet (45.7M)
2021-04-12T12:40:38.35-0400 [CELL/0] OUT Starting health monitoring of container
2021-04-12T12:40:40.72-0400 [APP/PROC/WEB/0] ERR (node:15) [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
2021-04-12T12:40:40.72-0400 [APP/PROC/WEB/0] ERR (Use node --trace-warnings ... to show where the warning was created)
2021-04-12T12:40:40.75-0400 [APP/PROC/WEB/0] OUT Server is running at http://127.0.0.1:8080
2021-04-12T12:40:40.75-0400 [APP/PROC/WEB/0] OUT Try http://127.0.0.1:8080/ping
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR Connection fails: Error: Password contains an illegal unescaped character
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR It will be retried for the next request.
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR node:events:356
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR throw er; // Unhandled 'error' event
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR ^
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR Error: Password contains an illegal unescaped character
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at parseConnectionString (/home/vcap/app/node_modules/mongodb/lib/url_parser.js:304:13)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at parseHandler (/home/vcap/app/node_modules/mongodb/lib/url_parser.js:135:14)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at QueryReqWrap.callback (/home/vcap/app/node_modules/mongodb/lib/url_parser.js:119:7)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at QueryReqWrap.onresolve [as oncomplete] (node:dns:211:10)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR Emitted 'error' event on BackendDbDataSource instance at:
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at BackendDbDataSource.postInit (/home/vcap/app/node_modules/loopback-datasource-juggler/lib/datasource.js:502:16)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at onError (/home/vcap/app/node_modules/loopback-connector-mongodb/lib/mongodb.js:316:21)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at /home/vcap/app/node_modules/loopback-connector-mongodb/lib/mongodb.js:334:11
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at parseHandler (/home/vcap/app/node_modules/mongodb/lib/url_parser.js:140:16)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at QueryReqWrap.callback (/home/vcap/app/node_modules/mongodb/lib/url_parser.js:119:7)
2021-04-12T12:40:41.46-0400 [APP/PROC/WEB/0] ERR at QueryReqWrap.onresolve [as oncomplete] (node:dns:211:10)
2021-04-12T12:40:41.48-0400 [APP/PROC/WEB/0] OUT Exit status 1
manifest.yml
applications:
- name: oneseg-poc-backend
buildpack: nodejs_buildpack
stack: cflinuxfs3
env:
NODE_ENV: dev
memory: 256M instances: 1
## Expected Behavior
mongo connection: success
## Link to reproduction sandbox
<!--
See https://loopback.io/doc/en/contrib/Reporting-issues.html#loopback-3x-bugs
Note: Failure to provide a sandbox application for reproduction purposes will result in the issue being closed.
-->
## Additional information
$ node -e 'console.log(process.platform, process.arch, process.versions.node)'
my development env: win32 x64 14.15.4
$ npm ls --prod --depth 0 | grep loopback
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- [email protected]
## Related Issues
<!-- Did you find other bugs that looked similar? -->
_See [Reporting Issues](http://loopback.io/doc/en/contrib/Reporting-issues.html) for more tips on writing good issues_
I really need help, :( anyone?
I've tried all the posted solutions for this subject, but still getting this pesky error Password contains an illegal unescaped character. I've encoded the password but that doesn't help either. Help anyone?
2021-04-16T14:19:49.021-04:00 [APP/PROC/WEB/0] [OUT] databaseUrl: mongodb+srv://381761ba-9143-4822-94d4-e740ed4519ec:K4d5oeWrqMZW86mGq02cs5kyFTrc2VoD6l_6v-30cyw%[email protected]/default
2021-04-16T14:19:49.205-04:00 [APP/PROC/WEB/0] [ERR] (node:21) [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
2021-04-16T14:19:49.205-04:00 [APP/PROC/WEB/0] [ERR] (Use `node --trace-warnings ...` to show where the warning was created)
2021-04-16T14:19:49.232-04:00 [APP/PROC/WEB/0] [OUT] Server is running at http://127.0.0.1:8080
2021-04-16T14:19:49.232-04:00 [APP/PROC/WEB/0] [OUT] Try http://127.0.0.1:8080/ping
2021-04-16T14:19:49.945-04:00 [APP/PROC/WEB/0] [ERR] Connection fails: Error: Password contains an illegal unescaped character
2021-04-16T14:19:49.945-04:00 [APP/PROC/WEB/0] [ERR] It will be retried for the next request.
here is my loopback code, generated by lb4 datasource for mongodb:
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
const config = {
name: 'backendDB',
connector: 'loopback-connector-mongodb',
url: 'mongodb+srv://381761ba-9143-4822-94d4-e740ed4519ec:K4d5oeWrqMZW86mGq02cs5kyFTrc2VoD6l_6v-30cyw%[email protected]/default',
useNewUrlParser: true
};
// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The `stop()` method is inherited from `juggler.DataSource`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class BackendDbDataSource extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'backendDB';
static readonly defaultConfig = config;
constructor(
@inject('datasources.config.backendDB', {optional: true})
dsConfig: object = config,
) {
super(dsConfig);
}
}
Hi @mercale, this repo is for the older EOLed LoopBack 3 framework and isn't being actively monitored. LoopBack 4 is under https://github.com/strongloop/loopback-next.
cc: @dhmlau could you assist in transferring this issue? Thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.