[SOLVED] "mongooseUri" must be a valid uri


Looks like a problem with another npm module.

Attempting to connect to a MongoDB set, but getting message that the URI is invalid.

[Error [ValidationError]: "mongooseUri" must be a valid uri] {
  _original: {
    mongooseOptions: { useNewUrlParser: true, useUnifiedTopology: true },
    mongooseUri: 'mongodb://USERNAME:PASSWORD@lin-aaaa-xxxx.servers.linodedb.net:27017,lin-bbbb-yyyy.servers.linodedb.net:27017,lin-cccc-zzzz.servers.linodedb.net:27017/DATABASE?replicaSet=RS-abdc-99&ssl=true'
  details: [
      message: '"mongooseUri" must be a valid uri',
      path: [ 'mongooseUri' ],
      type: 'string.uri',
      context: {
        label: 'mongooseUri',
        value: 'mongodb://USERNAME:PASSWORD@lin-aaaa-xxxx.servers.linodedb.net:27017,lin-bbbb-yyyy.servers.linodedb.net:27017,lin-cccc-zzzz.servers.linodedb.net:27017/DATABASE?replicaSet=RS-abdc-99&ssl=true',
        key: 'mongooseUri'

The username/password/database don't contain any special characters. I didn't see anything reported with Mongoose. The format is a valid MongoDB connection string, so I'm at a loss. Any thoughts?

3 Replies

Comma (,) is an invalid character in URIs. It appears that your use of it is as a continuation character. I suggest you crack open your trusty python manual and see what the approved continuation character for multiline strings is.

I don't know anything about python…I've only inferred this from the data you posted. I could be way out in the weeds…

-- sw


You're reading the code block wrong. Those are single-quoted strings, and the markdown style is line-breaking on the , for display. I'm not doing that.

All I know is what I see. Looks like you're back to square one… Thanks for the clarification.

-- sw


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct