Arslan1997 commited on
Commit
d63809c
·
1 Parent(s): 8813709
Files changed (1) hide show
  1. src/routes/code_routes.py +15 -2
src/routes/code_routes.py CHANGED
@@ -712,10 +712,23 @@ async def fix_code(
712
  # Fallback if DSPy models are not initialized or there's an error
713
  logger.log_message(f"Error with DSPy models for user_id {user_id}: {str(e)}", level=logging.ERROR)
714
 
715
- # Return a helpful error message that doesn't expose implementation details
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  return {
717
  "fixed_code": request_data.code,
718
- "error": "Could not process fix request. Please try again later."
719
  }
720
  except Exception as e:
721
  logger.log_message(f"Error fixing code: {str(e)}", level=logging.ERROR)
 
712
  # Fallback if DSPy models are not initialized or there's an error
713
  logger.log_message(f"Error with DSPy models for user_id {user_id}: {str(e)}", level=logging.ERROR)
714
 
715
+ # Return the actual error details instead of generic message
716
+ error_message = str(e)
717
+
718
+ # Sanitize sensitive information but keep useful details
719
+ if "API key" in error_message.lower():
720
+ error_message = "API configuration error. Please contact support."
721
+ elif "timeout" in error_message.lower():
722
+ error_message = "Request timed out. Please try again."
723
+ elif "rate limit" in error_message.lower():
724
+ error_message = "Rate limit exceeded. Please wait a moment and try again."
725
+ elif len(error_message) > 200:
726
+ # Truncate very long error messages
727
+ error_message = error_message[:200] + "..."
728
+
729
  return {
730
  "fixed_code": request_data.code,
731
+ "error": error_message # Return actual error instead of generic message
732
  }
733
  except Exception as e:
734
  logger.log_message(f"Error fixing code: {str(e)}", level=logging.ERROR)