question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExpressReceiver InstallProvider should honor client provided logger

See original GitHub issue

Description

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:

  1. Create an ExpressReceiver providing a custom logger in the InstallerOptions
const boltReceiver = new ExpressReceiver({
    ...
    logger,
    installationStore: {
        ...
    },
    installerOptions: {
        ...
        logger,
    },
});
  1. Simulate a failure in your install provided.
  2. 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:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
seratchcommented, May 13, 2021

@kilianc The issue will be fixed in the next minor version (3.4.0) - https://github.com/slackapi/bolt-js/pull/856

1reaction
stevengillcommented, Sep 14, 2020

@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 of new ConsoleLogger(). Therefore, it will never allow the underlying OAuth library to create and set its own logger (which is what should happen in the case no logger is passed by the user).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the @slack/bolt.ExpressReceiver function in ...
ExpressReceiver examples, based on popular ways it is used in public projects. ... Enable debug logging if true const debug: boolean = true; ......
Read more >
Bolt for JavaScript - Slack Platform Developer Tools
A framework that makes Slack app development fast and straight-forward. With a single interface for Slack's Web API, Events API, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found