[SERVER-26623] call deleteOne with an array in shell Created: 13/Oct/16 Updated: 16/Nov/21 Resolved: 07/Feb/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 3.2.10 |
| Fix Version/s: | 3.5.3 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Jaap Taal | Assignee: | Jonathan Reams |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
macOSX (installed with brew) |
||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | OS X | ||||
| Sprint: | Platforms 2016-10-31, Platforms 2017-02-13 | ||||
| Participants: | |||||
| Linked BF Score: | 0 | ||||
| Description |
I accidentally ran deleteOne with an array. When you do that you should get an error, but I think this is an internal bug in the shell. BTW: I couldn't find the right project for the shell, so I filed it under tools. |
| Comments |
| Comment by Githook User [ 09/Feb/17 ] | |
|
Author: {u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}Message: | |
| Comment by Githook User [ 07/Feb/17 ] | |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: | |
| Comment by Githook User [ 07/Feb/17 ] | |
|
Author: {u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}Message: | |
| Comment by Jonathan Reams [ 02/Feb/17 ] | |
|
I think the problem here is that when we execute a bulk api it checks whether there are any errors and throws them as a BulkWriteError, which is just a fancy error - so by the time it reaches this code that I think is meant to convert an array of errors its already a single Error. I think we should just remove that try/catch block in all the single write APIs and let the bulk write API format the errors they way it wants. | |
| Comment by Jaap Taal [ 27/Oct/16 ] | |
|
If it's not fixable, this issue should be closed of course. | |
| Comment by Jaap Taal [ 27/Oct/16 ] | |
|
Fair enough, it's just that I tought that
was an error that usually indcates some precondition for a piece of code is violated. I was guessing it should be possible to raise a more specific error, because err is some internal variable. | |
| Comment by Mira Carey [ 26/Oct/16 ] | |
|
Unfortunately, the shell lacks the kind of pervasive argument checking necessary to validate that all forms of input are sane. In this particular case, you're experiencing JavaScript's inclination to treat Array's as Objects, and that the filter argument to deleteOne is a generic object, rather than some more formal type. Thus, [] becomes {}, which becomes deleteOne({}). Given that existing code out in the wild requires only that filter be an object (rather than having a specific prototype/constructor) it would be a backwards breaking change for us to begin constraining that space to specifically plain objects (or to one of our choosing). So while I'm sympathetic that array is clearly not a reasonable option, closing that loophole would leave:
Let alone equivalent problems across the entire shell javascript api. If we ever end up writing a new shell, with a new api, I'd be interested in a vastly more type-constrained interface. Unfortunately, that's not something that we can tackle at this time in the current shell codebase. | |
| Comment by Kelsey Schubert [ 13/Oct/16 ] | |
|
Hi q42jaap, Thank you for the report. I've assigned this issue to the Platforms Team to continue to investigate. Please continue to watch this ticket for updates. Kind regards, |