Skip to content

Enable developers to customize the way to handle unmatched requests  #273

Description

@seratch

If an incoming request does not match with any listeners in a Bolt app, the Bolt app responds to the request with 404 response status. The following lines of code are relevant parts in App / AsyncApp:

There is no way to append custom logic for the patterns. A common use case can be to customize the logging in the scenario.

To improve this, I'm thinking to change the behavior as below:

  • Add a new Bolt specific exception BoltUnhandledRequestError(BoltError) here and enable @app.error listener to handle the pattern
  • Change App / AsyncApp internals. If a request is unhandled, App/AsncApp raises BoltUnhandledRequestError and lets @app.error listener handle it. If @app.error listener does not return any BoltResponse or set status to the response argument, App/AsncApp falls back to the current logic, which outputs simple log message and returns 404 status anyway.
  • As with the current implementation, non-200 responses are ignored in Socket Mode

If there is no concern about this change, we'll apply the change in the next minor version (1.5.0).

Category (place an x in each of the [ ])

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Activity

  1. added this to the 1.5.0 milestone on Mar 29, 2021
  2. self-assigned this
    on Mar 29, 2021
  3. eddyg commented on Mar 29, 2021

    @eddyg
    Contributor

    This proposal sounds great to me, Kaz. I like that it uses the existing @app.error listener.

  4. Shadrocks commented on Apr 6, 2021

    @Shadrocks

    I have a lot of these filling up my logs also. Is there documentation that can just help me to understand what the root cause of this is?

  5. seratch commented on Apr 12, 2021

    @seratch
    ContributorAuthor

    @Shadrocks Your app does not have the listeners for incoming requests. I would recommend enabling debug-level logging (https://slack.dev/bolt-python/concepts#logging) and checking what types of payloads to your app. If you have questions regarding this topic, please file a new GitHub issue for the question (we are using this issue for a new feature development - it'd be appreciated if you could understand this).

  6. seratch commented on Apr 12, 2021

    @seratch
    ContributorAuthor

    I was going to modify the internals of bolt-python not to bring any breaking changes to the existing apps but I found that it's not feasible as a single bolt app can have only one @app.error listener function.

    For this reason, I'd propose introducing a new flag to explicitly turn the new behavior on - raise_error_for_unhandled_request. As I will submit the pull request, see the details in the PR changes.

  7. changed the title [-]Enable developers to customize the way to handle unmtached requests [/-] [+]Enable developers to customize the way to handle unmatched requests [/+] on Apr 12, 2021
  8. added a commit that references this issue on Apr 19, 2021
    684611c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions