litellm/ui/litellm-dashboard/src/utils/errorPatterns.ts
Cole McIntosh ae74eb833b
Implement health check frontend UI components and dashboard integration (#11679)
* feat: Implement health check functionality for models

- Added individual model health check API call and integrated it into the dashboard.
- Introduced health check history and latest health checks retrieval.
- Enhanced model dashboard to display health status, last check time, and error details.
- Created a new health check columns component for better organization of health data.
- Added error pattern handling for meaningful error messages.
- Updated UI components to support health check actions and display loading states.

* refactor: extract health check functionality into a new component

- Removed individual health check logic from ModelDashboard and encapsulated it within HealthCheckComponent for better modularity and maintainability.
- Updated ModelDashboard to utilize the new HealthCheckComponent, streamlining the health check process and improving code organization.
- Cleaned up unused state variables and imports related to health checks in ModelDashboard.
- Enhanced error handling and status management within the new component, ensuring a more robust health check experience.

* fix: add access token check in HealthCheckComponent to prevent unauthorized API calls

- Implemented a check for the presence of an access token before making API calls to fetch the latest health checks, enhancing security and preventing potential errors when the token is missing.
2025-06-18 13:46:40 -07:00

53 lines
No EOL
1.3 KiB
TypeScript

export interface ErrorPattern {
pattern: RegExp;
replacement: string;
}
// Centralised list of common error patterns.
// Add new patterns here without touching component files.
export const errorPatterns: ErrorPattern[] = [
// Generic missing API key (covers OpenAI, Anthropic, etc.)
{
pattern: /Missing .* API Key/i,
replacement: 'Missing API Key',
},
// Network / connectivity issues
{
pattern: /Connection timeout/i,
replacement: 'Connection timeout',
},
{
pattern: /Network.*not.*ok/i,
replacement: 'Network connection failed',
},
// HTTP status based errors
{
pattern: /403.*Forbidden/i,
replacement: 'Access forbidden - check API key permissions',
},
{
pattern: /401.*Unauthorized/i,
replacement: 'Unauthorized - invalid API key',
},
{
pattern: /429.*rate limit/i,
replacement: 'Rate limit exceeded',
},
{
pattern: /500.*Internal Server Error/i,
replacement: 'Provider internal server error',
},
// LiteLLM specific wrapped errors
{
pattern: /litellm\.AuthenticationError/i,
replacement: 'Authentication failed',
},
{
pattern: /litellm\.RateLimitError/i,
replacement: 'Rate limit exceeded',
},
{
pattern: /litellm\.APIError/i,
replacement: 'API error',
},
];