forked from phoenix/litellm-mirror
(feat) improve error for testing slack
This commit is contained in:
parent
0b85061086
commit
ebaf2eef1f
1 changed files with 39 additions and 18 deletions
|
@ -6497,27 +6497,48 @@ async def health_services_endpoint(
|
||||||
|
|
||||||
Used by the UI to let user check if slack alerting is working as expected.
|
Used by the UI to let user check if slack alerting is working as expected.
|
||||||
"""
|
"""
|
||||||
global general_settings, proxy_logging_obj
|
try:
|
||||||
|
global general_settings, proxy_logging_obj
|
||||||
|
|
||||||
if service is None:
|
if service is None:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400, detail={"error": "Service must be specified."}
|
status_code=400, detail={"error": "Service must be specified."}
|
||||||
)
|
)
|
||||||
|
|
||||||
if service not in ["slack_budget_alerts"]:
|
if service not in ["slack_budget_alerts"]:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail={
|
detail={
|
||||||
"error": f"Service must be in list. Service={service}. List={['slack_budget_alerts']}"
|
"error": f"Service must be in list. Service={service}. List={['slack_budget_alerts']}"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if "slack" in general_settings.get("alerting", []):
|
if "slack" in general_settings.get("alerting", []):
|
||||||
await proxy_logging_obj.alerting_handler(message="This is a test", level="Low")
|
await proxy_logging_obj.alerting_handler(
|
||||||
else:
|
message="This is a test", level="Low"
|
||||||
raise HTTPException(
|
)
|
||||||
status_code=422,
|
else:
|
||||||
detail={"error": "No slack connection setup. Unable to test this."},
|
raise HTTPException(
|
||||||
|
status_code=422,
|
||||||
|
detail={
|
||||||
|
"error": '"slack" not in proxy config: general_settings. Unable to test this.'
|
||||||
|
},
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
if isinstance(e, HTTPException):
|
||||||
|
raise ProxyException(
|
||||||
|
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
|
||||||
|
type="auth_error",
|
||||||
|
param=getattr(e, "param", "None"),
|
||||||
|
code=getattr(e, "status_code", status.HTTP_401_UNAUTHORIZED),
|
||||||
|
)
|
||||||
|
elif isinstance(e, ProxyException):
|
||||||
|
raise e
|
||||||
|
raise ProxyException(
|
||||||
|
message="Authentication Error, " + str(e),
|
||||||
|
type="auth_error",
|
||||||
|
param=getattr(e, "param", "None"),
|
||||||
|
code=status.HTTP_401_UNAUTHORIZED,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue