{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/comments/222704424","pull_request_review_id":161655486,"id":222704424,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjcwNDQyNA==","diff_hunk":"@@ -209,23 +209,25 @@ class OperationBuilder {\n         validationOptions = { validationLevel: this.s.options.validationLevel };\n       }\n \n-      // validate options\n-      const optionsIndex =\n-        typeof args[args.length - 1] === 'function' ? args.length - 2 : args.length - 1;\n+      const callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined;\n+      const options = typeof args[operationBuilder.requiredArity] === 'object' ? args.pop(): {};","path":"lib/options_validator.js","position":null,"original_position":8,"commit_id":"8233bda44aa5a062362b0c394f95c436490bd520","original_commit_id":"96fb3bd118c9bae92dfcb32b7a2f5e68d4542f48","user":{"login":"daprahamian","id":7957497,"node_id":"MDQ6VXNlcjc5NTc0OTc=","avatar_url":"https://avatars3.githubusercontent.com/u/7957497?v=4","gravatar_id":"","url":"https://api.github.com/users/daprahamian","html_url":"https://github.com/daprahamian","followers_url":"https://api.github.com/users/daprahamian/followers","following_url":"https://api.github.com/users/daprahamian/following{/other_user}","gists_url":"https://api.github.com/users/daprahamian/gists{/gist_id}","starred_url":"https://api.github.com/users/daprahamian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daprahamian/subscriptions","organizations_url":"https://api.github.com/users/daprahamian/orgs","repos_url":"https://api.github.com/users/daprahamian/repos","events_url":"https://api.github.com/users/daprahamian/events{/privacy}","received_events_url":"https://api.github.com/users/daprahamian/received_events","type":"User","site_admin":false},"body":"In this test case:\r\n\r\n```js\r\nconst fn = arityOne().options({...}).build(...);\r\nfn({a: 1}, {b: 2}, () => {}, callback);\r\n```\r\n\r\nThis line will confirm `typeof {b: 2} === 'object'`, but then pop `() => {}` as the options object. I want to double check: will `assertArity` catch this, and warn before this happens?","created_at":"2018-10-04T14:56:30Z","updated_at":"2018-10-04T14:57:04Z","html_url":"https://github.com/mongodb/node-mongodb-native/pull/1841#discussion_r222704424","pull_request_url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/comments/222704424"},"html":{"href":"https://github.com/mongodb/node-mongodb-native/pull/1841#discussion_r222704424"},"pull_request":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841"}}},"pull_request":{"url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841","id":219716170,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5NzE2MTcw","html_url":"https://github.com/mongodb/node-mongodb-native/pull/1841","diff_url":"https://github.com/mongodb/node-mongodb-native/pull/1841.diff","patch_url":"https://github.com/mongodb/node-mongodb-native/pull/1841.patch","issue_url":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/1841","number":1841,"state":"open","locked":false,"title":"fix(options_validator): add options if they do not exist","user":{"login":"kvwalker","id":7121013,"node_id":"MDQ6VXNlcjcxMjEwMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7121013?v=4","gravatar_id":"","url":"https://api.github.com/users/kvwalker","html_url":"https://github.com/kvwalker","followers_url":"https://api.github.com/users/kvwalker/followers","following_url":"https://api.github.com/users/kvwalker/following{/other_user}","gists_url":"https://api.github.com/users/kvwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/kvwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvwalker/subscriptions","organizations_url":"https://api.github.com/users/kvwalker/orgs","repos_url":"https://api.github.com/users/kvwalker/repos","events_url":"https://api.github.com/users/kvwalker/events{/privacy}","received_events_url":"https://api.github.com/users/kvwalker/received_events","type":"User","site_admin":false},"body":"While working on [NODE-1671](https://jira.mongodb.org/browse/NODE-1671), I realized that I was not handling the case where an operation is called without any options.\r\n\r\nIf `insertOne(doc, callback)` is called before this fix, the `doc` will be treated as `options` in `build()`. This fix ensures that a new options object is created if one is not passed in.","created_at":"2018-10-02T14:05:24Z","updated_at":"2018-10-04T14:57:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b41689b88f07a42ae2ec8888653faeef09f8a6c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841/commits","review_comments_url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841/comments","review_comment_url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/1841/comments","statuses_url":"https://api.github.com/repos/mongodb/node-mongodb-native/statuses/8233bda44aa5a062362b0c394f95c436490bd520","head":{"label":"kvwalker:NODE-1670-fix","ref":"NODE-1670-fix","sha":"8233bda44aa5a062362b0c394f95c436490bd520","user":{"login":"kvwalker","id":7121013,"node_id":"MDQ6VXNlcjcxMjEwMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7121013?v=4","gravatar_id":"","url":"https://api.github.com/users/kvwalker","html_url":"https://github.com/kvwalker","followers_url":"https://api.github.com/users/kvwalker/followers","following_url":"https://api.github.com/users/kvwalker/following{/other_user}","gists_url":"https://api.github.com/users/kvwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/kvwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvwalker/subscriptions","organizations_url":"https://api.github.com/users/kvwalker/orgs","repos_url":"https://api.github.com/users/kvwalker/repos","events_url":"https://api.github.com/users/kvwalker/events{/privacy}","received_events_url":"https://api.github.com/users/kvwalker/received_events","type":"User","site_admin":false},"repo":{"id":133556011,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1NTYwMTE=","name":"node-mongodb-native","full_name":"kvwalker/node-mongodb-native","private":false,"owner":{"login":"kvwalker","id":7121013,"node_id":"MDQ6VXNlcjcxMjEwMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7121013?v=4","gravatar_id":"","url":"https://api.github.com/users/kvwalker","html_url":"https://github.com/kvwalker","followers_url":"https://api.github.com/users/kvwalker/followers","following_url":"https://api.github.com/users/kvwalker/following{/other_user}","gists_url":"https://api.github.com/users/kvwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/kvwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvwalker/subscriptions","organizations_url":"https://api.github.com/users/kvwalker/orgs","repos_url":"https://api.github.com/users/kvwalker/repos","events_url":"https://api.github.com/users/kvwalker/events{/privacy}","received_events_url":"https://api.github.com/users/kvwalker/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kvwalker/node-mongodb-native","description":"Mongo DB Native NodeJS Driver","fork":true,"url":"https://api.github.com/repos/kvwalker/node-mongodb-native","forks_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/forks","keys_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/teams","hooks_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/hooks","issue_events_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/issues/events{/number}","events_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/events","assignees_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/assignees{/user}","branches_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/branches{/branch}","tags_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/tags","blobs_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/statuses/{sha}","languages_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/languages","stargazers_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/stargazers","contributors_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/contributors","subscribers_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/subscribers","subscription_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/subscription","commits_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/contents/{+path}","compare_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/merges","archive_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/downloads","issues_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/issues{/number}","pulls_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/pulls{/number}","milestones_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/milestones{/number}","notifications_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/labels{/name}","releases_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/releases{/id}","deployments_url":"https://api.github.com/repos/kvwalker/node-mongodb-native/deployments","created_at":"2018-05-15T18:19:17Z","updated_at":"2018-10-01T13:20:32Z","pushed_at":"2018-10-04T14:24:13Z","git_url":"git://github.com/kvwalker/node-mongodb-native.git","ssh_url":"git@github.com:kvwalker/node-mongodb-native.git","clone_url":"https://github.com/kvwalker/node-mongodb-native.git","svn_url":"https://github.com/kvwalker/node-mongodb-native","homepage":"http://mongodb.github.com/node-mongodb-native/","size":88395,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mongodb:next","ref":"next","sha":"070aa231973e16790af143479007bc8245b4435a","user":{"login":"mongodb","id":45120,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTIw","avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":462292,"node_id":"MDEwOlJlcG9zaXRvcnk0NjIyOTI=","name":"node-mongodb-native","full_name":"mongodb/node-mongodb-native","private":false,"owner":{"login":"mongodb","id":45120,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTIw","avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mongodb/node-mongodb-native","description":"Mongo DB Native NodeJS Driver","fork":false,"url":"https://api.github.com/repos/mongodb/node-mongodb-native","forks_url":"https://api.github.com/repos/mongodb/node-mongodb-native/forks","keys_url":"https://api.github.com/repos/mongodb/node-mongodb-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/node-mongodb-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/node-mongodb-native/teams","hooks_url":"https://api.github.com/repos/mongodb/node-mongodb-native/hooks","issue_events_url":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/node-mongodb-native/events","assignees_url":"https://api.github.com/repos/mongodb/node-mongodb-native/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/node-mongodb-native/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/node-mongodb-native/tags","blobs_url":"https://api.github.com/repos/mongodb/node-mongodb-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/node-mongodb-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/node-mongodb-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/node-mongodb-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/node-mongodb-native/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/node-mongodb-native/languages","stargazers_url":"https://api.github.com/repos/mongodb/node-mongodb-native/stargazers","contributors_url":"https://api.github.com/repos/mongodb/node-mongodb-native/contributors","subscribers_url":"https://api.github.com/repos/mongodb/node-mongodb-native/subscribers","subscription_url":"https://api.github.com/repos/mongodb/node-mongodb-native/subscription","commits_url":"https://api.github.com/repos/mongodb/node-mongodb-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/node-mongodb-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/node-mongodb-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/node-mongodb-native/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/node-mongodb-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/node-mongodb-native/merges","archive_url":"https://api.github.com/repos/mongodb/node-mongodb-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/node-mongodb-native/downloads","issues_url":"https://api.github.com/repos/mongodb/node-mongodb-native/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/node-mongodb-native/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/node-mongodb-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/node-mongodb-native/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/node-mongodb-native/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/node-mongodb-native/deployments","created_at":"2010-01-07T12:50:50Z","updated_at":"2018-10-04T11:30:00Z","pushed_at":"2018-10-04T14:24:15Z","git_url":"git://github.com/mongodb/node-mongodb-native.git","ssh_url":"git@github.com:mongodb/node-mongodb-native.git","clone_url":"https://github.com/mongodb/node-mongodb-native.git","svn_url":"https://github.com/mongodb/node-mongodb-native","homepage":"http://mongodb.github.com/node-mongodb-native/","size":91509,"stargazers_count":7301,"watchers_count":7301,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1373,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1373,"open_issues":16,"watchers":7301,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841"},"html":{"href":"https://github.com/mongodb/node-mongodb-native/pull/1841"},"issue":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/1841"},"comments":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/issues/1841/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/pulls/1841/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/node-mongodb-native/statuses/8233bda44aa5a062362b0c394f95c436490bd520"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"daprahamian"}}