nexu-io/open-design · error · RuntimeError

requests library not available for webhook delivery

Error message

requests library not available for webhook delivery

What it means

Raised in _send_slack_webhook (and _send_generic_webhook) when the module-level `requests` symbol is None. watchlist.py imports requests in a try/except ImportError block, setting requests=None on failure; the webhook senders gate on `if not requests` and refuse to deliver because there is no HTTP client to POST with.

Source

Thrown at design-templates/last30days/scripts/watchlist.py:62


def _format_delivery_message(topic: str, counts: dict, mode: str) -> str:
    """Format notification message based on delivery mode."""
    new = counts.get("new", 0)
    updated = counts.get("updated", 0)

    if mode == "announce":
        return f"📰 *last30days update: {topic}*\n{new} new, {updated} updated"
    elif mode == "silent":
        return f"last30days: {new} new findings for '{topic}'"
    else:
        return f"last30days: Research complete for '{topic}'"


def _send_slack_webhook(url: str, text: str) -> None:
    """POST to Slack incoming webhook."""
    if not requests:
        raise RuntimeError("requests library not available for webhook delivery")

    response = requests.post(
        url,
        json={"text": text},
        headers={"Content-Type": "application/json"},
        timeout=10,
    )
    response.raise_for_status()


def _send_generic_webhook(url: str, text: str) -> None:
    """POST JSON payload to generic webhook."""
    if not requests:
        raise RuntimeError("requests library not available for webhook delivery")

    response = requests.post(
        url,
        json={

View on GitHub (pinned to 5be4028344)

Solutions

  1. Install requests in the environment: pip install requests (or add it to the project requirements).
  2. If you cannot install requests, disable webhook delivery (clear the delivery_channel setting) so watchlist skips the send path entirely.
  3. Note the outer _deliver_findings already wraps the call in try/except and prints to stderr, so a missing requests will not crash the research run, only the notification.

Example fix

# before (requests missing)
# delivery fails: 'requests library not available for webhook delivery'

# after
pip install requests
# or, in watchlist config, leave delivery_channel empty to skip delivery
Defensive patterns

Strategy: validation

Validate before calling

def can_deliver_webhook():
    import importlib.util
    return importlib.util.find_spec("requests") is not None

# before scheduling delivery:
if not can_deliver_webhook():
    print("requests not installed; webhook delivery disabled", file=sys.stderr)

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Running watchlist delivery while the `requests` package is not installed in the active Python environment. The pipeline's own http module may use urllib, but watchlist delivery specifically requires the third-party requests library.

Common situations: Slim container/venv that installed only the pipeline deps but not requests. Running watchlist.py under a different interpreter than the one that pip-installed dependencies. requests removed during a dependency cleanup.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/547d9c900a08b0f9. Report an issue: GitHub.