zulip / zulipbot

GitHub workflow-optimizing bot by @zulip
Other
84 stars 65 forks source link

Fix @octokit/rest deprecations #192

Closed garg3133 closed 3 years ago

garg3133 commented 3 years ago

The number parameter is deprecated in octokit/rest and issue_number and pull_number parameters are used now for all methods related to issues and pulls respectively.

Also, response.code is deprecated in octokit promise response and response.status is used now.

Here's the error stack:

2021-01-28T11:57:44.763718+00:00 app[web.1]: { Deprecation: [@octokit/request-error] `error.code` is deprecated, use `error.status`.
2021-01-28T11:57:44.763729+00:00 app[web.1]:     at RequestError.get (/app/node_modules/@octokit/request/node_modules/@octokit/request-error/dist-node/index.js:29:17)
2021-01-28T11:57:44.763730+00:00 app[web.1]:     at Object.exports.run (/app/src/commands/claim.js:37:18)
2021-01-28T11:57:44.763730+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:68:7) name: 'Deprecation' }
2021-01-28T11:57:44.766479+00:00 app[web.1]: { Deprecation: [@octokit/rest] "number" parameter is deprecated for ".issues.createComment()". Use "issue_number" instead
2021-01-28T11:57:44.766480+00:00 app[web.1]:     at Object.keys.forEach.key (/app/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js:13145:26)
2021-01-28T11:57:44.766481+00:00 app[web.1]:     at Array.forEach (<anonymous>)
2021-01-28T11:57:44.766482+00:00 app[web.1]:     at Object.patchedMethod [as createComment] (/app/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js:13142:26)
2021-01-28T11:57:44.766482+00:00 app[web.1]:     at Object.invite (/app/src/commands/claim.js:84:24)
2021-01-28T11:57:44.766483+00:00 app[web.1]:     at Object.exports.run (/app/src/commands/claim.js:44:19)
2021-01-28T11:57:44.766483+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:68:7) name: 'Deprecation' }

Fixed both the deprecations in this pull request.

Note: I used issue_comment parameter in template.getComments() becuase issues api is being used in this method. https://github.com/zulip/zulipbot/blob/a68d0db8731d8d0357a28d470d96251d4fc5f037/src/structures/Template.js#L30

codecov[bot] commented 3 years ago

Codecov Report

Merging #192 (dac8044) into master (e23ff5c) will increase coverage by 0.22%. The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   41.44%   41.66%   +0.22%     
==========================================
  Files          20       21       +1     
  Lines         596      600       +4     
==========================================
+ Hits          247      250       +3     
- Misses        349      350       +1     
andersk commented 3 years ago

The unit tests needed to be updated for the last commit. Otherwise looks good, thanks!