Skip to content

Granular error handling needed in claude_service.py for external APIs, DB, JSON, and file I/O #28

@KrishnaRaheja

Description

@KrishnaRaheja

Problem
In claude_service.py, the following errors are not handled with sufficient granularity:

  • Anthropic API errors: Only generic exceptions are caught; specific Anthropic errors (such as network issues, invalid API key, malformed request, quota exceeded) are not distinguished or retried.
  • Supabase errors: Any database failure (connection, query, insert) is caught generically; there is no custom handling for rate limits, schema mismatches, or partial failures.
  • JSON serialization errors: If preference or tool results contain unserializable objects, this could raise exceptions not specifically handled.
  • File I/O errors: Reading the system prompt file is not wrapped in its own try/except block; if the file is missing or unreadable, it will cause a generic exception.
  • Type errors: If tool input is missing required fields or has wrong types, only some cases are checked; others may cause runtime errors.
  • Adapter errors: If FastFlightsAdapter fails (e.g., external API down, invalid parameters), only generic exceptions are caught.

Summary
Exceptions are caught as generic errors and logged, without specific handling, retry mechanisms, or user-friendly messaging for different error types. The function returns an error string for any failure, making debugging and user experience difficult.

Expected improvement:

  • Implement granular error handling for each failure type (network, authentication, serialization, database, file, etc.).
  • Add retries, specific logging, and user-focused error messages.
  • Consider custom exception classes or error codes for clarity.
  • Improve resilience and maintainability of claude_service.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions