{"record":{"id":"6f1e4bcec05f6184","repo":"BerriAI/litellm","slug":"invalid-webhook-url-value-for-webhook-urls-got","errorCode":null,"errorMessage":"Invalid webhook url value for: {webhook_urls}. Got type={type(_env_value)}","messagePattern":"Invalid webhook url value for: (.+?)\\. Got type=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/SlackAlerting/utils.py","lineNumber":48,"sourceCode":"    for alert_type, webhook_urls in alert_to_webhook_url.items():\n        if isinstance(webhook_urls, list):\n            _webhook_values: list[str] = []\n            for webhook_url in webhook_urls:\n                if \"os.environ/\" in webhook_url:\n                    _env_value = get_secret(secret_name=webhook_url)\n                    if not isinstance(_env_value, str):\n                        raise ValueError(f\"Invalid webhook url value for: {webhook_url}. Got type={type(_env_value)}\")\n                    _webhook_values.append(_env_value)\n                else:\n                    _webhook_values.append(webhook_url)\n\n            alert_to_webhook_url[alert_type] = _webhook_values\n        else:\n            _webhook_value_str: str = webhook_urls\n            if \"os.environ/\" in webhook_urls:\n                _env_value = get_secret(secret_name=webhook_urls)\n                if not isinstance(_env_value, str):\n                    raise ValueError(f\"Invalid webhook url value for: {webhook_urls}. Got type={type(_env_value)}\")\n                _webhook_value_str = _env_value\n            else:\n                _webhook_value_str = webhook_urls\n\n            alert_to_webhook_url[alert_type] = _webhook_value_str\n\n    return alert_to_webhook_url\n\n\nasync def _add_langfuse_trace_id_to_alert(\n    request_data: dict | None = None,\n) -> str | None:\n    \"\"\"\n    Returns langfuse trace url\n\n    - check:\n    -> existing_trace_id\n    -> trace_id","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/SlackAlerting/utils.py#L30-L66","documentation":"LiteLLM's Slack alerting lets you reference webhook URLs indirectly via the special 'os.environ/ENV_VAR_NAME' syntax in `alert_to_webhook_url`. At startup, `process_slack_alerting_variables` resolves each such reference through `get_secret` and requires the result to be a plain string. If the secret manager returns None (var not set) or a non-string (e.g. a dict from a secret backend), this ValueError is raised. The message reports the offending reference and the actual Python type it got.","triggerScenarios":"Calling `litellm.alerting()` or constructing SlackAlerting with `alert_to_webhook_url={'llm_api_latency_alert': 'os.environ/SLACK_WEBHOOK_URL_1'}` when SLACK_WEBHOOK_URL_1 is unset, or when the secret is stored in a connected secret manager (e.g. AWS/Kubernetes) under a non-string value. Also triggered with a list of URLs where one element is an 'os.environ/...' reference that resolves to None.","commonSituations":"Typo in the env var name after 'os.environ/'; forgetting to export the var in the deployment shell/docker-compose/k8s manifest; secret manager returning a JSON object instead of a raw string; CI environments where the webhook var is only set in one job.","solutions":["Verify the env var actually exists and holds a string: run `echo $SLACK_WEBHOOK_URL_1` (or print `os.getenv('SLACK_WEBHOOK_URL_1')`) in the same environment where litellm runs","Fix the reference spelling so the name after 'os.environ/' exactly matches the exported variable name","If the value lives in a secret manager, ensure it is stored as a plain string secret, not a JSON blob/key-value payload","As a quick unblock, replace the 'os.environ/...' reference with the literal webhook URL to confirm the rest of the alerting config is correct"],"exampleFix":"# before\nalert_to_webhook_url = {\n    \"llm_api_latency_alert\": \"os.environ/SLACK_WEBHOOK_URL\",  # var not exported -> resolves to None\n}\nlitellm.alerting=[\"slack\"]\n\n# after\n# export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T000/B000/XXXX first, then\nalert_to_webhook_url = {\n    \"llm_api_latency_alert\": \"os.environ/SLACK_WEBHOOK_URL\",\n}","handlingStrategy":"validation","validationCode":"import os\n\ndef webhook_refs_ok(alert_to_webhook_url: dict) -> None:\n    for alert_type, urls in alert_to_webhook_url.items():\n        candidates = urls if isinstance(urls, list) else [urls]\n        for u in candidates:\n            if isinstance(u, str) and u.startswith(\"os.environ/\"):\n                name = u.split(\"os.environ/\", 1)[1]\n                val = os.getenv(name)\n                if not isinstance(val, str) or not val:\n                    raise SystemExit(f\"Missing env var {name} for Slack webhook ({alert_type})\")\n\nwebhook_refs_ok({\"llm_api_latency_alert\": \"os.environ/SLACK_WEBHOOK_URL_1\"})","typeGuard":"def is_resolvable_webhook_ref(ref: str) -> bool:\n    import os\n    if not isinstance(ref, str):\n        return False\n    if ref.startswith(\"os.environ/\"):\n        return isinstance(os.getenv(ref.split(\"os.environ/\", 1)[1]), str)\n    return True","tryCatchPattern":"try:\n    litellm.alerting = [\"slack\"]  # triggers webhook resolution\nexcept ValueError as e:\n    if \"Invalid webhook url value\" in str(e):\n        log.error(\"Slack webhook env var unresolved\", extra={\"detail\": str(e)})\n        # degrade: disable alerting rather than crash the app\n        litellm.alerting = None\n    else:\n        raise","preventionTips":["Add webhook env vars to the same env checklist as API keys in deploy scripts","Use fail-fast startup checks for every 'os.environ/...' reference in alerting config","Prefer literal webhook URLs in dev environments to isolate secret-resolution issues"],"tags":["slack","webhook","environment-variable","secret-manager","alerting"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}