Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Remove redundant exception from logger.exception and add pre-commit check

LearningCircuit2145bcb01c2c
diff --git a/.pre-commit-hooks/custom-checks.py b/.pre-commit-hooks/custom-checks.py
index b8f362419e..7f813a465d 100755
--- a/.pre-commit-hooks/custom-checks.py
+++ b/.pre-commit-hooks/custom-checks.py
@@ -6,6 +6,7 @@ Checks for:
2. If logger.exception is used instead of logger.error for error handling
3. That no raw SQL is used, only ORM methods
4. That ORM models (classes inheriting from Base) are defined in models/ folders
+5. That logger.exception doesn't include redundant {e} in the message
"""
import ast
@@ -323,6 +324,19 @@ def check_file(filename: str) -> bool:
print(f"Error reading {filename}: {e}")
return False
+ # Check for logger.exception with redundant {e}
+ lines = content.split("\n")
+ for i, line in enumerate(lines, 1):
+ # Match logger.exception with f-string containing {e}, {exc}, {ex}, etc.
+ if re.search(
+ r'logger\.exception\s*\(\s*[fF]?["\'].*\{(?:e|ex|exc|exception)\}.*["\']',
+ line,
+ ):
+ print(
+ f"{filename}:{i}: logger.exception automatically includes exception details, remove {{e}} from message"
+ )
+ return False
+
# Parse AST for logging checks
try:
tree = ast.parse(content, filename=filename)
diff --git a/src/local_deep_research/news/api.py b/src/local_deep_research/news/api.py
index 94f4d8937a..868f862b22 100644
--- a/src/local_deep_research/news/api.py
+++ b/src/local_deep_research/news/api.py
@@ -148,8 +148,8 @@ def get_news_feed(
metadata = row["research_meta"]
else:
metadata = json.loads(row["research_meta"])
- except (json.JSONDecodeError, TypeError) as e:
- logger.exception(f"Error parsing metadata: {e}")
+ except (json.JSONDecodeError, TypeError):
+ logger.exception("Error parsing metadata")
metadata = {}
# Check if this has news metadata (generated_headline or generated_topics)
@@ -368,11 +368,10 @@ def get_news_feed(
if len(news_items) >= limit:
break
- except Exception as e:
+ except Exception:
error_count += 1
- logger.exception(f"Error processing research item: {e}")
logger.exception(
- f"Failed item query: {row.get('query', 'UNKNOWN')[:100]}"
+ f"Error processing research item with query: {row.get('query', 'UNKNOWN')[:100]}"
)
continue
@@ -418,7 +417,7 @@ def get_news_feed(
}
except Exception as e:
- logger.exception(f"Error getting news feed: {e}")
+ logger.exception("Error getting news feed")
return {"error": str(e), "news_items": []}
@@ -606,7 +605,7 @@ def get_subscription_history(
}
except Exception as e:
- logger.exception(f"Error getting subscription history: {e}")
+ logger.exception("Error getting subscription history")
return {"error": str(e), "history": []}
@@ -635,8 +634,8 @@ def _format_time_ago(timestamp: str) -> str:
return f"{minutes} minute{'s' if minutes > 1 else ''} ago"
else:
return "Just now"
- except Exception as e:
- logger.exception(f"Error parsing timestamp '{timestamp}': {e}")
+ except Exception:
+ logger.exception(f"Error parsing timestamp '{timestamp}'")
return "Recently"
@@ -691,8 +690,8 @@ def get_subscription(subscription_id: str) -> Optional[Dict[str, Any]]:
else None,
}
- except Exception as e:
- logger.exception(f"Error getting subscription {subscription_id}: {e}")
+ except Exception:
+ logger.exception(f"Error getting subscription {subscription_id}")
return None
@@ -754,7 +753,7 @@ def get_subscriptions(user_id: str) -> Dict[str, Any]:
return {"subscriptions": sub_list, "total": len(sub_list)}
except Exception as e:
- logger.exception(f"Error getting subscriptions: {e}")
+ logger.exception("Error getting subscriptions")
return {"error": str(e), "subscriptions": []}
@@ -893,7 +892,7 @@ def update_subscription(
}
except Exception as e:
- logger.exception(f"Error updating subscription: {e}")
+ logger.exception("Error updating subscription")
return {"error": str(e)}
@@ -1003,8 +1002,8 @@ def create_subscription(
"refresh_hours": refresh_hours,
}
- except Exception as e:
- logger.exception(f"Error creating subscription: {e}")
+ except Exception:
+ logger.exception("Error creating subscription")
raise
@@ -1075,7 +1074,7 @@ def delete_subscription(subscription_id: str) -> Dict[str, Any]:
else:
return {"error": "Subscription not found", "status": "error"}
except Exception as e:
- logger.exception(f"Error deleting subscription: {e}")
+ logger.exception("Error deleting subscription")
return {"error": str(e), "status": "error"}