{"record":{"id":"c252d000a689dd59","repo":"BerriAI/litellm","slug":"missing-webhook-url-from-environment","errorCode":null,"errorMessage":"Missing webhook_url from environment","messagePattern":"Missing webhook_url from environment","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/SlackAlerting/slack_alerting.py","lineNumber":1061,"sourceCode":"\n    async def model_removed_alert(self, model_name: str):\n        pass\n\n    async def send_webhook_alert(self, webhook_event: WebhookEvent) -> bool:\n        \"\"\"\n        Sends structured alert to webhook, if set.\n\n        Currently only implemented for budget alerts\n\n        Returns -> True if sent, False if not.\n\n        Raises Exception\n            - if WEBHOOK_URL is not set\n        \"\"\"\n\n        webhook_url: Final = os.getenv(\"WEBHOOK_URL\", None)\n        if webhook_url is None:\n            raise Exception(\"Missing webhook_url from environment\")\n\n        payload: Final = webhook_event.model_dump_json()\n        headers: Final = {\"Content-type\": \"application/json\"}\n\n        response: Final = await self.async_http_handler.post(\n            url=webhook_url,\n            headers=headers,\n            data=payload,\n        )\n        if response.status_code == 200:\n            return True\n        else:\n            print(\"Error sending webhook alert. Error=\", response.text)  # noqa: T201\n\n        return False\n\n    async def _check_if_using_premium_email_feature(\n        self,","sourceCodeStart":1043,"sourceCodeEnd":1079,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/SlackAlerting/slack_alerting.py#L1043-L1079","documentation":"SlackAlerting.send_webhook posts a structured (currently budget) alert to a raw webhook URL taken exclusively from the WEBHOOK_URL environment variable (litellm/integrations/SlackAlerting/slack_alerting.py:1058-1061). Unlike the Slack paths, this method does not consult alert_to_webhook_url or default_webhook_url, so an unset WEBHOOK_URL aborts with an Exception.","triggerScenarios":"Enabling alerting with budget alerts ('budget_alerts' in the alerts list) and calling send_webhook without WEBHOOK_URL in the proxy process env; docker compose / k8s deployments missing the WEBHOOK_URL env entry; shell-exported variable not visible to the service user.","commonSituations":"Proxy operators configuring Slack via SLACK_WEBHOOK_URL but the budget-alert path needing the differently-named WEBHOOK_URL; secrets managed in config files while this code path reads only os.environ; CI smoke tests of alerting without env setup.","solutions":["Set WEBHOOK_URL in the environment of the litellm proxy process and restart it.","If you meant Slack alerts generally, configure general_settings.alerting with webhook URLs and SLACK_WEBHOOK_URL instead of relying on send_webhook.","In docker-compose/k8s, add WEBHOOK_URL to env/envFrom and verify with a printenv exec inside the container.","Wrap send_webhook calls in try/except and log clearly when alert delivery is not configured."],"exampleFix":"# before\n# docker-compose.yml has no WEBHOOK_URL\nawait alerting.send_webhook(webhook_event)  # Exception: Missing webhook_url from environment\n\n# after\n# docker-compose.yml\n environment:\n   - WEBHOOK_URL=https://hooks.example.com/xxx\nawait alerting.send_webhook(webhook_event)","handlingStrategy":"validation","validationCode":"import os\n\nwebhook_url = os.getenv(\"WEBHOOK_URL\")\nif webhook_url is None:\n    raise RuntimeError(\"WEBHOOK_URL not set; required for send_webhook budget alerts\")\n# safe to call: await alerting.send_webhook(webhook_event)","typeGuard":null,"tryCatchPattern":"try:\n    sent = await alerting.send_webhook(webhook_event)\nexcept Exception as e:\n    if \"Missing webhook_url from environment\" in str(e):\n        # degrade gracefully: log locally, alert via another channel, do not crash the request path\n        logger.warning(\"budget alert not delivered: WEBHOOK_URL unset\")\n    else:\n        raise","preventionTips":["Declare WEBHOOK_URL in the deployment env spec whenever budget alerts are enabled.","Add a boot-time env audit listing required alerting variables per enabled feature.","Never let alert-delivery failures crash user-facing requests — catch and log them."],"tags":["litellm","slack-alerting","budget-alerts","webhook","environment-variable"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}