Commit Graph

4 Commits

Author SHA1 Message Date
leex279
f8a3054906 cleanup: Remove debug logging and finalize OpenAI error handling
Clean production-ready version with:
- Comprehensive OpenAI error handling (401, 429, 502)
- Proper error message sanitization
- ProjectServiceError structure handling
- Enhanced user-friendly error messages
- TanStack Query integration

Successfully resolves Issue #362 - users now get immediate clear
error messages instead of silent failures and 90-minute debugging sessions.
2025-09-12 20:18:41 +02:00
leex279
43bbb6629a fix: Properly handle ProjectServiceError structure from ETag client
The callAPIWithETag function extracts error messages from backend responses
but loses the structured error details. Enhanced wrapper now reconstructs
the full error structure based on status codes and error messages.

- Add specific handling for ProjectServiceError class
- Reconstruct OpenAI error details from extracted messages
- Preserve error_type and structured message information
- Add comprehensive debug logging to trace error parsing

This ensures OpenAI authentication/quota errors are properly recognized
and display the correct user-friendly messages in the UI.
2025-09-12 20:12:15 +02:00
leex279
082324b7fc debug: Add comprehensive logging to trace error handling flow
- Add detailed logging to API key validation function
- Add debug logs to frontend error parsing
- Add debug logs to TanStack Query error handler
- This will help identify where error handling is failing in the UI
2025-09-12 19:47:47 +02:00
leex279
98b798173e feat: Implement comprehensive OpenAI error handling for Issue #362
Replace silent failures with clear, actionable error messages to eliminate
90-minute debugging sessions when OpenAI API quota is exhausted.

## Backend Enhancements
- Add error sanitization preventing sensitive data exposure (API keys, URLs, tokens)
- Add upfront API key validation before expensive operations (crawl, upload, refresh)
- Implement fail-fast pattern in RAG service (no more empty results for API failures)
- Add specific error handling for quota, rate limit, auth, and API errors
- Add EmbeddingAuthenticationError exception with masked key prefix support

## Frontend Enhancements
- Create enhanced error utilities with OpenAI-specific parsing
- Build TanStack Query compatible API wrapper preserving ETag caching
- Update knowledge service to use enhanced error handling
- Enhance TanStack Query hooks with user-friendly error messages

## Security Features
- Comprehensive regex sanitization (8 patterns) with ReDoS protection
- Input validation and circular reference detection
- Generic fallback messages for sensitive keywords
- Bounded quantifiers to prevent regex DoS attacks

## User Experience
- Clear error messages: "OpenAI API quota exhausted"
- Actionable guidance: "Check your OpenAI billing dashboard and add credits"
- Immediate error visibility (no more silent failures)
- Appropriate error severity styling

## Architecture Compatibility
- Full TanStack Query integration maintained
- ETag caching and optimistic updates preserved
- No performance regression (all existing tests pass)
- Compatible with existing knowledge base architecture

Resolves #362: Users no longer experience mysterious empty RAG results
that require extensive debugging to identify OpenAI quota issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 19:22:36 +02:00