diff --git a/tests/test_litellm/proxy/common_utils/test_callback_utils.py b/tests/test_litellm/proxy/common_utils/test_callback_utils.py index 985e8d20be7..20f979ab4d3 100644 --- a/tests/test_litellm/proxy/common_utils/test_callback_utils.py +++ b/tests/test_litellm/proxy/common_utils/test_callback_utils.py @@ -73,6 +73,32 @@ def test_process_callback_with_no_required_env_vars(mock_get_env_vars): assert result["variables"] == {} +@patch( + "litellm.proxy.common_utils.callback_utils.CustomLogger.get_callback_env_vars", + return_value=[], +) +def test_process_callback_returns_correct_type_for_each_callback_mode(mock_get_env_vars): + """ + Verify that process_callback returns the correct 'type' field for success, + failure, and success_and_failure callback modes. The UI relies on this field + to display the correct mode badge. + + Regression test: the UI was reading 'mode' instead of 'type', causing all + callbacks to display as 'Success'. The frontend was fixed to read 'type'. + This test ensures the backend contract is maintained. + """ + for callback_type in ["success", "failure", "success_and_failure"]: + result = process_callback( + _callback="s3_v2", + callback_type=callback_type, + environment_variables={}, + ) + assert result["type"] == callback_type, ( + f"Expected type '{callback_type}', got '{result['type']}'" + ) + assert result["name"] == "s3_v2" + + def test_normalize_callback_names_none_returns_empty_list(): assert normalize_callback_names(None) == [] assert normalize_callback_names([]) == [] diff --git a/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/LoggingCallbacksTable.tsx b/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/LoggingCallbacksTable.tsx index 8f332d0317a..31b2698fb35 100644 --- a/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/LoggingCallbacksTable.tsx +++ b/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/LoggingCallbacksTable.tsx @@ -57,7 +57,7 @@ export const LoggingCallbacksTable: React.FC = ({ title: Mode, key: "mode", render: (_: unknown, record: CallbackRow) => { - const mode = record.mode || "success"; + const mode = record.type || record.mode || "success"; const label = CALLBACK_MODES.find((m) => m.value === mode)?.label || mode; const badgeClass = mode === "success" diff --git a/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/types.ts b/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/types.ts index 2fc180e49f3..b1f34c89e20 100644 --- a/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/types.ts +++ b/ui/litellm-dashboard/src/components/Settings/LoggingAndAlerts/LoggingCallbacks/types.ts @@ -1,6 +1,7 @@ export interface AlertingObject { name: string; variables: AlertingVariables; + type?: "success" | "failure" | "success_and_failure" | string; } export interface AlertingVariables {