-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(core): Support WiredTiger engine errmsg format in MongoDB 3.2 #1246
Conversation
Seems a better solution than previously proposed hacks. Haven't tried it yet. |
Just tried it. No issues for me. I am running mongod 3.2.3 but the mongodb libraries that npm installs are 2.1.7 (I think that is strange but it works). |
@tfernandez The latest driver is 2.1.7 |
Possibly my data is not in WiredTiger since I upgraded an existing database. |
Yup, existing db file will cause mongodb to use old MMapV1 engine (default engine in mongodb 3.0). |
// >= 3.2 11000 duplicate key error collection: mean-test.users index: username already exists | ||
// < 3.2 Username already exists | ||
userInfoRes.body.message.toLowerCase().should.containEql('username already exists'); | ||
userInfoRes.body.message.should.equal('Username already exists'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't needed. using toLowerCase()
and containEql()
is better here.
@QiyuLi This looks pretty good. I left a few comments. Thanks for the fix :) |
@mleanos
I will change it to |
@QiyuLi I don't think we need the assertion there to be precise. Also, the assert should have zero impact on what is displayed to the user. IMO, it's just an unnecessary change. With that said, I'm fine with you leaving it the way you have it, since it was originally that way before the recent changes; unless someone else has objections. Thanks for explaining your reasoning. |
The new WiredTiger engine is introduced in MongoDB 3.2. It changes the output errmsg format for violation of unique index. This commit adds support for the new format. Fixes meanjs#1245
8268ae7
to
6265aaa
Compare
@mleanos I re-submit the commit including the fix |
@QiyuLi Thank you. LGTM now. @lirantal @ilanbiala @codydaig LGTY? Also, are |
@QiyuLi Why add in more complex support and revert the changes instead of using the looser validation that covers both? |
@ilanbiala https://cloud.githubusercontent.com/assets/5421502/13476128/5fab7546-e094-11e5-9e37-e4394f7653f8.png I think it is solving a usability issue in the ui too. The test is giving a valid alert and should not be loosened. |
@ilanbiala trendzetter did a good summary. |
I have come to understand that this issue and pr should account as a serious warning about code quality and applying best practices. I didn't know at the time I loosened the tests what I was actually doing because I wasn't very familiar with the tests and the issue didn't show up with me. Someone forwarded me this "fix" to include. Good tests should not be fixed rather the code should be fixed to behave according to the use cases. I should not have been allowed to modify the tests. If someone suggests to fix the tests you should always question if there is really something wrong with the tests or is it mangling the tests to suit the issue. |
Adds the mongoose-beautiful-unique-validation package, and implements it on the Sign Up server controller, as a proof of concept. Would like to get others to test this using various MongoDB versions; preferably versions > 3.0.7 The implementation seems pretty simple, and we can choose when to use it since it requires exposes `trySave` as a save method that will implement the Beautiful Unique Validator. Related meanjs#1246
We definitely need to reconcile the differences in the validation errors that newer versions of MongoDB are generating. That's the main point of the fix here. As for whether or not the tests need to change, it's up for debate. The decision was made previously to use To be clear, the asserts (in the tests) have no bearing on what messages are sent to the UI. I think there might be some confusion there with the terminology. I think the fix here is fine, and don't have a super strong opinion whether or not to change the assertions. @simison mentioned a possible solution with the |
@mleanos I disagree that it is a good decision to add containEql and tolowercase.
I am not sure if I understand you correctly here. The tests do test what is send to the UI, right? Isn't testing what is in the UI exactly the point of e2e tests? |
What i meant was that we're merely assertng against what is sent to the Ui. So if we use |
The e2E test should give an error if what is send is not acceptable output. The exact check does that but the loosened check doesn't. |
@trendzetter You're definitely making a good point. However, I'm not sure we have to be so strict in this case. With that said, I'm fine with the change in this PR. |
@mleanos If you are not strict you allow for all kinds of weirdness to get through, exactly the opposite of why you added tests. The goal of the e2e or system tests is to get an early warning during development that you have broken end user functionality. This test did in fact just that. I (and others) didn't respond correctly by changing the test instead of looking for the issue. One should only change the old test to the new if the test is checking things that aren't required. I would say that in the case of our software, clear readable errors with normal casing and punctuation is a requirement (although I haven't seen any formal requirements or use cases for this software). Am I making sense or do I give the impression of a weird fanatic? I can't stress enough how important it is to have the correct understanding about this if you want to benefit from testing. |
@trendzetter I totally understand, and you're just trying to get your point across. I thank you for that. Let's wait to see if others have an opinion, and if @ilanbiala has more insight. As I said before, I'm indifferent about the use of |
@trendzetter might be right, but honestly I question our use of the error message directly in the UI. I think that's also an issue. Let's just stick with |
@QiyuLi I think this is ready. I'll merge over the weekend, if no other concerns are brought up. |
Sorry for the negative tone. I will be glad if those line are restored. It was really a shameful mistake I managed to sneak in. its encouraging and refreshing seeing others catching such mistakes. |
@trendzetter remember that contributing to open source is all about team work, being polite and compromising sometimes. And thanks for your and anyone else's efforts on meanjs! Have a fun and good day. :-) |
👍 |
fix(core): Support WiredTiger engine errmsg format in MongoDB 3.2
Thank you @QiyuLi & @trendzetter for helping out here. |
The new WiredTiger engine is introduced in MongoDB 3.2.
It changes the output errmsg format for violation of unique index.
This commit adds support for the new format.
Fixes #1245