Skip to content

fix: align WSGI/ASGI test infrastructure and handler with spec#1513

Open
WilliamBergamin wants to merge 8 commits into
mainfrom
imporve-asgi-wsgi-remove-deps
Open

fix: align WSGI/ASGI test infrastructure and handler with spec#1513
WilliamBergamin wants to merge 8 commits into
mainfrom
imporve-asgi-wsgi-remove-deps

Conversation

@WilliamBergamin
Copy link
Copy Markdown
Contributor

Summary

Use stdlib wsgiref.validate and asgiref.testing to ensure test servers are fully PEP 3333 / ASGI spec-compliant.

This also removes dependencies we were not using, and audit the implementation of the WSGI and ASGI adapters

Testing

Continuous integration pipeline should be sufficient

If you want to test it out locally

# requirements.txt
pytest==9.0.3
ruff==0.15.12
uvicorn[standard]
aiohttp
path/to/bolt-python/dist/slack_bolt-1.28.0-py2.py3-none-any.whl
slack-cli-hooks<1.0.0
import os
import logging

from slack_bolt.async_app import AsyncApp
from slack_bolt.adapter.asgi.async_handler import AsyncSlackRequestHandler

logging.basicConfig(level=logging.DEBUG)

app = AsyncApp(
    token=os.environ.get("SLACK_BOT_TOKEN"),
    signing_secret="your signing secret",
)


@app.event("app_home_opened")
async def app_home_opened(client, event, logger):
    if event["tab"] != "home":
        return
    try:
        await client.views_publish(
            user_id=event["user"],
            view={
                "type": "home",
                "blocks": [
                    {
                        "type": "section",
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Welcome home, <@" + event["user"] + "> :house:*",
                        },
                    },
                    {
                        "type": "section",
                        "text": {
                            "type": "mrkdwn",
                            "text": "Learn how home tabs can be more useful and "
                            + "interactive <https://api.slack.com/surfaces/tabs/using|*in the documentation*>.",
                        },
                    },
                ],
            },
        )
    except Exception as e:
        logger.error(f"Error publishing home tab: {e}")


api = AsyncSlackRequestHandler(app)
{
    "_metadata": {
        "major_version": 1,
        "minor_version": 1
    },
    "display_information": {
        "name": "test-asgi-adapter"
    },
    "features": {
        "app_home": {
            "home_tab_enabled": true,
            "messages_tab_enabled": false,
            "messages_tab_read_only_enabled": true
        },
        "bot_user": {
            "display_name": "test-asgi-adapter",
            "always_online": false
        }
    },
    "oauth_config": {
        "scopes": {
            "bot": [
                "chat:write"
            ]
        }
    },
    "settings": {
        "event_subscriptions": {
            "bot_events": [
                "app_home_opened"
            ]
        },
        "interactivity": {
            "is_enabled": false
        },
        "org_deploy_enabled": true,
        "socket_mode_enabled": false,
        "token_rotation_enabled": false
    }
}
uvicorn app:api --port 3000 --log-level trace

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • 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.

  • 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 run ./scripts/install_all_and_run_tests.sh after making the changes.

@WilliamBergamin WilliamBergamin added this to the 1.29.0 milestone May 29, 2026
@WilliamBergamin WilliamBergamin self-assigned this May 29, 2026
@WilliamBergamin WilliamBergamin requested a review from a team as a code owner May 29, 2026 22:02
@WilliamBergamin WilliamBergamin added area:adapter dependencies Pull requests that update a dependency file tests semver:patch labels May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.28%. Comparing base (e8222b5) to head (b94bc21).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
slack_bolt/adapter/asgi/http_response.py 85.71% 1 Missing ⚠️
slack_bolt/adapter/wsgi/handler.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1513      +/-   ##
==========================================
- Coverage   91.30%   91.28%   -0.03%     
==========================================
  Files         228      228              
  Lines        7271     7275       +4     
==========================================
+ Hits         6639     6641       +2     
- Misses        632      634       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:adapter dependencies Pull requests that update a dependency file semver:patch tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant