question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Regex does not match all Mongo Error structures

See original GitHub issue

Using Mongo version 3.2.4 installed on Ubuntu 14.04

It seems as if the errorRegex (index.js#L6) you are using does not match all structures of E11000 duplicate key errors.

For example: https://regex101.com/r/lA2dZ7/1


Error Regex

var errorRegex = /index:\s*.+?\.\$(\S*)\s*dup key:\s*\{(.*?)\}/;

Matching Error Structure

E11000 duplicate key error index: database-name.users.$username_1 dup key: { : "andrew" }

Non-matching Error Structure

E11000 duplicate key error collection: database-name.users index: username_1 dup key: { : "andrew" }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
galenandrewcommented, Mar 17, 2016

The updated regex appears to match all scenarios: https://regex101.com/r/lA2dZ7/2

Correct @Fonger?

1reaction
galenandrewcommented, Mar 16, 2016

Will do!

Read more comments on GitHub >

github_iconTop Results From Across the Web

regex with mongolite in R - mongodb - Stack Overflow
Trying to do a regex match with the awesome ...
Read more >
Improved Error Messages for Schema Validation in MongoDB ...
First, let's look at the new error message. It is a structured message in the BSON format, explaining which part of the document...
Read more >
How To Use Schema Validation in MongoDB - DigitalOcean
In MongoDB, the database engine feature that makes it possible to apply constraints on the document structure is called Schema Validation ...
Read more >
MongoDB NOT operator ( $not ) - GeeksforGeeks
This operator is used to perform logical NOT operation on the specified operator expressions and select or retrieve only those documents that do...
Read more >
4. Querying - MongoDB: The Definitive Guide, 2nd Edition [Book]
The find method is used to perform queries in MongoDB. Querying returns a subset of documents in a collection, from no documents at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found