ExpressReceiver InstallProvider should honor client provided logger
See original GitHub issueDescription
The ExpressReceiver OAuth InstallProvider uses the default logger regardless of whether a custom logger is provided in the installer options. Note, the WebClient used by the OAuth package does properly wire up the custom logger.
Note: I have a one-liner PR ready that adds the logger includes the logger when newing up the InstallProvider.
Example of my json transport logs inner mixed with the default bolt console logger…
{"level":"DEBUG","message":"apiCall('oauth.v2.access') start","line":148,"function":"apiCall","file":"node_modules/@slack/oauth/node_modules/@slack/web-api/src/WebClient.ts"}
{"level":"DEBUG","message":"will perform http request","line":308,"function":null,"file":"node_modules/@slack/oauth/node_modules/@slack/web-api/src/WebClient.ts"}
{"level":"DEBUG","message":"http response received","line":316,"function":null,"file":"node_modules/@slack/oauth/node_modules/@slack/web-api/src/WebClient.ts"}
[ERROR] OAuth:InstallProvider:0 [Error: An API error occurred: invalid_code] {
code: 'slack_webapi_platform_error',
data: { ok: false, error: 'invalid_code', response_metadata: {} }
}
What type of issue is this? (place an x
in one of the [ ]
)
- bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Requirements (place an x
in each of the [ ]
)
- I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
- I’ve read and agree to the Code of Conduct.
- I’ve searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 2.3.0
node version: v14.9.0 OS version(s): MacOS Catalina 10.15.6 (19G2021)
Steps to reproduce:
- Create an ExpressReceiver providing a custom logger in the InstallerOptions
const boltReceiver = new ExpressReceiver({
...
logger,
installationStore: {
...
},
installerOptions: {
...
logger,
},
});
- Simulate a failure in your install provided.
- Observe logs and note that the error log is not coming from your custom logger.
Expected result:
What you expected to happen custom logger should be used by the OAuth InstallProvider.
Actual result:
The default logger is used.
Attachments:
{"level":"DEBUG","message":"http response received","line":316,"function":null,"file":"node_modules/@slack/oauth/node_modules/@slack/web-api/src/WebClient.ts"}
[ERROR] OAuth:InstallProvider:0 [Error: An API error occurred: invalid_code] {
code: 'slack_webapi_platform_error',
data: { ok: false, error: 'invalid_code', response_metadata: {} }
}
should be something like:
{"level":"ERROR","message":"An API error occurred: invalid_code","line":302,"function":null,"file":"node_modules/@slack/oauth/src/index.ts"}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
@kilianc The issue will be fixed in the next minor version (3.4.0) - https://github.com/slackapi/bolt-js/pull/856
@aoberoi this is what is intended and it is a bug. I actually ended up fixing this one recently on my branch feat-socket-mode. I should probably have ripped it out into its own PR since it isn’t related to the work there.
I’ll comment on your PR @chris-skud with a couple of changes. The issue with the current solution in your PR is that if logger wasn’t passed in by the developer,
ExpressReceiver
sets a default ofnew ConsoleLogger()
. Therefore, it will never allow the underlyingOAuth
library to create and set its own logger (which is what should happen in the case no logger is passed by the user).