probot: Warning for `error.code` is deprecated, use `error.status`

Bug Report

Current Behavior

In @octokit/rest we’re seeing a deprecation warning for error.code:

`error.code` is deprecated, use `error.status`

This is from here, in Context#config:

https://github.com/probot/probot/blob/99784f3607dd9d4e4681b12a673757a9ac30b3b8/src/context.ts#L176-L178

It’s not a super-simple fix, because change it here causes tests to fail without the tests being updated - and that causes TypeScript errors:

image

So we’ll have to update the types as well.

@gr2m since we’re using our own types for the OctokitError class - what’s more correct here?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (7 by maintainers)

Most upvoted comments

I’m still getting this on probot v9.2.20.

{ Deprecation: [@octokit/request] `error.code` is deprecated, use `error.status`.
    at HttpError.get (.../node_modules/@octokit/rest/node_modules/@octokit/request/lib/http-error.js:18:17)
    at Object.Logger.stdSerializers.err (.../node_modules/bunyan/lib/bunyan.js:1148:19)
    at .../node_modules/bunyan/lib/bunyan.js:873:50
    at Array.forEach (<anonymous>)
    at Logger._applySerializers (.../node_modules/bunyan/lib/bunyan.js:865:35)
    at mkRecord (.../node_modules/bunyan/lib/bunyan.js:978:17)
    at Logger.error (.../node_modules/bunyan/lib/bunyan.js:1044:19)
    at Application.<anonymous> (.../node_modules/probot/lib/application.js:159:33)
    at step (.../node_modules/probot/lib/application.js:43:23)
    at Object.throw (.../node_modules/probot/lib/application.js:24:53)
    at rejected (.../node_modules/probot/lib/application.js:16:65) name: 'Deprecation' }

Looks like it’s traced to the bunyan logging lib at lib/bunyan.js#L1146

error.status is correct, it’s a number. It used to be the status text, that is a breaking change that comes with v8, so we should update it in probot