Skip to content

**Actionable comments posted: 34** #70

@MasumRab

Description

@MasumRab

Actionable comments posted: 34

🔭 Outside diff range comments (2)
server/python_nlp/nlp_engine.py (1)

85-100: Loaded models are discarded – breaks _analyze_topic_model & friends

_sentiment_model_obj, _topic_model_obj, … are correctly loaded, but never assigned to the public attributes (self.sentiment_model, self.topic_model, …).
Any downstream helper (e.g. _analyze_topic_model(), _analyze_sentiment_model()) that still checks these attributes will see None and fall back every time.

         # Load models if dependencies are available
@@
         _urgency_model_obj = None
@@
             _urgency_model_obj = self._load_model(self.urgency_model_path)
 
-        # Initialize SentimentModel …
+        # Persist raw model objects for the legacy helpers
+        self.sentiment_model = _sentiment_model_obj
+        self.topic_model     = _topic_model_obj
+        self.intent_model    = _intent_model_obj
+        self.urgency_model   = _urgency_model_obj
+
+        # Initialize SentimentModel …
server/aiRoutes.test.ts (1)

215-218: Remove sentinel lines – TypeScript parser error

The closing marker made it into the source file and breaks compilation:

-});
-[end of server/aiRoutes.test.ts]
+});
🧹 Nitpick comments (24)
server/python_nlp/analysis_components/sentiment_model.py (1)

17-20: Consider defaulting has_nltk_installed parameter
Requiring callers to pass has_nltk_installed can lead to inconsistencies. You might refactor the constructor to default to the module-level HAS_NLTK flag:

-from typing import Optional, Dict, Any
-from .sentiment_model import HAS_NLTK
+from typing import Optional, Dict, Any
+from .sentiment_model import HAS_NLTK

 class SentimentModel:
-    def __init__(self, sentiment_model: Optional[Any], has_nltk_installed: bool):
+    def __init__(self, sentiment_model: Optional[Any], has_nltk_installed: bool = HAS_NLTK):
         self.model = sentiment_model
         self.has_nltk = has_nltk_installed
         self.logger = logging.getLogger(__name__)
server/python_backend/models.py (1)

135-140: Avoid using object as a field name

The field name object shadows the built-in object type, which can confuse static analysis tools and readers. Consider a more descriptive name such as target or item_object.

-class ActionItem(BaseModel):
-    action_phrase: str
-    verb: Optional[str] = None
-    object: Optional[str] = None
+class ActionItem(BaseModel):
+    action_phrase: str
+    verb: Optional[str] = None
+    target: Optional[str] = Field(None, alias="object")

Add alias="object" if the original payloads already use object.

server/categoryRoutes.ts (1)

20-34: POST / – surface validation details consistently

ZodError details are exposed, but the success branch omits a location header. Consider adding Location: /api/categories/{id} for REST semantics.

server/performanceRoutes.ts (1)

35-40: Consistent default response shape

overview || { … } may drift from the documented schema. Create a typed factory (e.g., emptyPerformanceOverview()) to guarantee field presence and keep the shape in sync between routes.

server/activityRoutes.ts (1)

23-37: Surface Zod validation details for any failure path

Only the happy‐path of the ZodError branch exposes error.errors; if other validation errors surface inside storage.createActivity, callers will only get a generic 500. Consider normalising error responses and logging the original error for observability.

Also note that returning Zod’s errors verbatim may leak internal schema details; you may want to map them to a more compact shape before sending them to clients.

server/python_nlp/tests/analysis_components/test_urgency_model.py (1)

45-63: Avoid coupling tests to private helpers

The suite calls the internal method _analyze_regex(). While useful, this couples the test to implementation details and can hinder refactors. Prefer validating public behaviour only and, if needed, expose a small helper through the public API for unit-level testing.

server/python_backend/tests/test_dashboard_routes.py (1)

52-74: Mock shape mismatch for weekly_growth

The comment notes that weekly_growth must conform to the Pydantic sub-model, then immediately overrides the mock dict. Prefer constructing one canonical fixture that matches the API contract and avoid the mid-test mutation.

Refactor for clarity and maintainability.

server/python_backend/tests/test_category_routes.py (1)

61-66: Consider returning 201 for resource creation

POST /api/categories currently returns 200, but REST conventions reserve 201 for successful creation. Aligning with the convention simplifies client-side expectations and allows the Location header in the future.

If you keep 200 intentionally, add a comment in the route explaining the choice to avoid confusion.

server/python_backend/category_routes.py (2)

53-55: pydantic v2 compatibility

CategoryCreate is a V2 model – favour model_dump() over dict() to respect alias & exclude rules:

-        created_category_dict = await db.create_category(category.dict())
+        created_category_dict = await db.create_category(category.model_dump())

22-33: Re-raise with context for clearer logs

Same B904 pattern as elsewhere:

-        raise HTTPException(status_code=503, detail="Database service unavailable.")
+        raise HTTPException(status_code=503, detail="Database service unavailable.") from db_err

Repeat for the other except blocks.

server/python_backend/dashboard_routes.py (1)

37-47: Chain underlying exceptions

To keep stack-traces intact:

-        raise HTTPException(status_code=503, detail="Database service unavailable.")
+        raise HTTPException(status_code=503, detail="Database service unavailable.") from db_err

Apply similarly in the generic except.

server/python_backend/tests/test_action_routes.py (1)

6-6: Remove unused import ActionItem.

ActionItem is imported but never referenced in this test module, producing an F401/unused-import warning and unnecessary coupling to model code.

-from server.python_backend.models import ActionItem # For response type hint if needed
+# (import not required)
server/python_backend/tests/test_email_routes.py (2)

5-8: Commented guidance can be dropped; it leaks internal context and clutters tests.

These inline remarks about import paths/dependency timing are useful while refactoring but should not remain in committed test code. They don’t add value to future readers and may become outdated.


63-66: dependency_overrides not cleaned up – risk of leakage to other test modules.

FastAPI keeps app.dependency_overrides after the test finishes.
Add a try/finally (or yield) in the client fixture to restore the original state:

@pytest.fixture
def client():
    from server.python_backend.database import get_db
-    app.dependency_overrides[get_db] = lambda: mock_db_manager
-    return TestClient(app)
+    app.dependency_overrides[get_db] = lambda: mock_db_manager
+    try:
+        yield TestClient(app)
+    finally:
+        app.dependency_overrides.clear()
server/python_nlp/tests/analysis_components/test_sentiment_model.py (1)

97-99: if __name__ == "__main__": unittest.main() is redundant under pytest.

Pytest discovers and runs unittest.TestCase classes automatically.
Keeping the manual runner is harmless but unnecessary noise.

server/gmailRoutes.ts (1)

8-37: Repeated try/catch + console.* blocks – extract reusable error handler.

Every route repeats identical error handling. Consider a helper:

const wrap =
  (fn: express.RequestHandler): express.RequestHandler =>
  async (req, res) => {
    try {
      await fn(req, res);
    } catch (err) {
      console.error(err);
      res.status(500).json({
        success: false,
        error: err instanceof Error ? err.message : "Unknown error",
      });
    }
  };

and then router.post("/sync", wrap(async (req,res)=>{ … })).

This removes duplication and guarantees consistent behaviour across future routes.

server/categoryRoutes.test.ts (1)

78-114: Zod-error branch is currently un-testable

The note in-code is correct: mocking storage.createCategory does not exercise the Zod-parsing branch because parsing happens before hitting storage.
Either (a) switch these tests to supertest so the request flows through the real validator or (b) export the raw handler from categoryRoutes.ts and invoke it directly with a crafted ZodError.

Until then this test is a false positive.

server/python_backend/tests/test_ai_engine.py (1)

16-36: Redundant reassignment of analyze_email

patch.object(NLPEngine, 'analyze_email') already replaces the method for every instance.
engine.nlp_engine.analyze_email = mock_nlp_analyze is redundant and may hide leaks if the patch is reverted.
Safe to delete the reassignment line.

server/python_backend/ai_engine.py (1)

70-96: Import DatabaseManager under TYPE_CHECKING to silence F821

Ruff flags DatabaseManager as undefined even though it only appears in type hints.
Add a guarded import to keep runtime deps unchanged and satisfy static analysis:

+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:           # for type-checkers / linters only
+    from server.python_backend.database import DatabaseManager
server/python_backend/filter_routes.py (2)

2-3: Drop unused typing.* imports

List, Dict, Any are never referenced – they only add noise.

-from typing import List, Dict, Any
+from typing import Any  # if really needed, otherwise remove entirely

90-100: Re-raise DB errors with context

Inside the except psycopg2.Error as db_err: block, re-raise with from db_err to preserve traceback:

-raise HTTPException(status_code=503, detail="Database service unavailable.")
+raise HTTPException(status_code=503,
+                    detail="Database service unavailable.") from db_err
server/python_backend/gmail_routes.py (2)

2-2: Remove unused typing imports

List, Dict, Any are not used; keep the file lean.


21-24: Heavy services created at import time

Instantiating DatabaseManager() and AdvancedAIEngine() at module import can slow startup, hamper unit-tests, and make configuration via env-vars impossible. Wire them via FastAPI Depends or a factory in startup events.

server/aiRoutes.ts (1)

46-55: Leverage optional chaining for cleaner null-checks.

The pattern if (analysis && analysis.categoryId) { ... } is repeated several times.
Using analysis?.categoryId (and similar) makes the intent clearer and satisfies the linter warning (useOptionalChain).

-if (analysis && analysis.categoryId) {
+if (analysis?.categoryId) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dac0f2e and 5a2161a.

📒 Files selected for processing (42)
  • server/activityRoutes.test.ts (1 hunks)
  • server/activityRoutes.ts (1 hunks)
  • server/ai-engine.ts (1 hunks)
  • server/aiRoutes.test.ts (1 hunks)
  • server/aiRoutes.ts (1 hunks)
  • server/categoryRoutes.test.ts (1 hunks)
  • server/categoryRoutes.ts (1 hunks)
  • server/dashboardRoutes.test.ts (1 hunks)
  • server/dashboardRoutes.ts (1 hunks)
  • server/emailRoutes.test.ts (1 hunks)
  • server/emailRoutes.ts (1 hunks)
  • server/gmailRoutes.test.ts (1 hunks)
  • server/gmailRoutes.ts (1 hunks)
  • server/performanceRoutes.ts (1 hunks)
  • server/python-bridge.ts (2 hunks)
  • server/python_backend/action_routes.py (1 hunks)
  • server/python_backend/ai_engine.py (2 hunks)
  • server/python_backend/category_routes.py (1 hunks)
  • server/python_backend/dashboard_routes.py (1 hunks)
  • server/python_backend/email_routes.py (1 hunks)
  • server/python_backend/filter_routes.py (1 hunks)
  • server/python_backend/gmail_routes.py (1 hunks)
  • server/python_backend/main.py (1 hunks)
  • server/python_backend/models.py (1 hunks)
  • server/python_backend/tests/test_action_routes.py (1 hunks)
  • server/python_backend/tests/test_ai_engine.py (1 hunks)
  • server/python_backend/tests/test_category_routes.py (1 hunks)
  • server/python_backend/tests/test_dashboard_routes.py (1 hunks)
  • server/python_backend/tests/test_email_routes.py (1 hunks)
  • server/python_backend/tests/test_filter_routes.py (1 hunks)
  • server/python_backend/tests/test_gmail_routes.py (1 hunks)
  • server/python_nlp/analysis_components/intent_model.py (1 hunks)
  • server/python_nlp/analysis_components/sentiment_model.py (1 hunks)
  • server/python_nlp/analysis_components/topic_model.py (1 hunks)
  • server/python_nlp/analysis_components/urgency_model.py (1 hunks)
  • server/python_nlp/gmail_service.py (6 hunks)
  • server/python_nlp/nlp_engine.py (2 hunks)
  • server/python_nlp/tests/analysis_components/test_intent_model.py (1 hunks)
  • server/python_nlp/tests/analysis_components/test_sentiment_model.py (1 hunks)
  • server/python_nlp/tests/analysis_components/test_topic_model.py (1 hunks)
  • server/python_nlp/tests/analysis_components/test_urgency_model.py (1 hunks)
  • server/routes.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (23)
server/dashboardRoutes.ts (1)
server/storage.ts (1)
  • storage (304-304)
server/categoryRoutes.ts (2)
shared/schema.ts (2)
  • categories (11-17)
  • insertCategorySchema (111-113)
server/storage.ts (1)
  • storage (304-304)
server/python_nlp/tests/analysis_components/test_topic_model.py (1)
server/python_nlp/analysis_components/topic_model.py (3)
  • TopicModel (7-94)
  • analyze (82-94)
  • _analyze_keyword (33-80)
server/dashboardRoutes.test.ts (2)
server/python_backend/models.py (1)
  • DashboardStats (275-283)
server/storage.ts (1)
  • storage (304-304)
server/python_backend/category_routes.py (3)
server/python_backend/database.py (2)
  • DatabaseManager (18-662)
  • get_db (665-672)
server/python_backend/models.py (2)
  • CategoryCreate (91-92)
  • CategoryResponse (94-96)
server/python_backend/performance_monitor.py (2)
  • PerformanceMonitor (50-566)
  • track (482-487)
server/emailRoutes.ts (2)
shared/schema.ts (2)
  • emails (19-94)
  • insertEmailSchema (115-117)
server/storage.ts (1)
  • storage (304-304)
server/python-bridge.ts (1)
server/ai-engine.ts (2)
  • AIAnalysis (18-18)
  • AccuracyValidation (28-28)
server/python_backend/tests/test_category_routes.py (3)
server/python_backend/category_routes.py (1)
  • create_category (46-75)
server/python_backend/database.py (1)
  • get_db (665-672)
server/python_backend/tests/test_email_routes.py (1)
  • client (62-66)
server/python_backend/tests/test_dashboard_routes.py (3)
server/python_backend/dashboard_routes.py (1)
  • get_dashboard_stats (16-47)
server/python_backend/database.py (1)
  • get_db (665-672)
server/python_backend/tests/test_email_routes.py (1)
  • client (62-66)
server/python_backend/action_routes.py (3)
server/python_backend/ai_engine.py (2)
  • AdvancedAIEngine (51-270)
  • analyze_email (97-119)
server/python_backend/performance_monitor.py (2)
  • PerformanceMonitor (50-566)
  • track (482-487)
server/python_backend/models.py (2)
  • ActionExtractionRequest (131-133)
  • ActionItem (135-140)
server/python_backend/tests/test_ai_engine.py (2)
server/python_backend/ai_engine.py (3)
  • AdvancedAIEngine (51-270)
  • AIAnalysisResult (18-49)
  • analyze_email (97-119)
server/python_nlp/nlp_engine.py (2)
  • NLPEngine (56-798)
  • analyze_email (681-748)
server/python_backend/dashboard_routes.py (3)
server/python_backend/database.py (2)
  • DatabaseManager (18-662)
  • get_db (665-672)
server/python_backend/performance_monitor.py (2)
  • PerformanceMonitor (50-566)
  • track (482-487)
server/python_backend/models.py (1)
  • DashboardStats (275-283)
server/python_nlp/tests/analysis_components/test_sentiment_model.py (1)
server/python_nlp/analysis_components/sentiment_model.py (3)
  • SentimentModel (16-142)
  • analyze (124-142)
  • _analyze_keyword (85-122)
server/emailRoutes.test.ts (1)
server/storage.ts (1)
  • storage (304-304)
server/gmailRoutes.ts (2)
server/gmail-ai-service.ts (1)
  • gmailAIService (403-403)
server/python_backend/metrics.py (1)
  • metrics (106-111)
server/python_backend/tests/test_gmail_routes.py (2)
server/python_nlp/gmail_service.py (4)
  • sync_gmail_emails (121-159)
  • execute_smart_retrieval (523-558)
  • get_retrieval_strategies (560-576)
  • get_performance_metrics (578-608)
server/python_backend/gmail_routes.py (1)
  • get_retrieval_strategies (175-189)
server/python_backend/tests/test_email_routes.py (4)
server/python_backend/database.py (5)
  • search_emails (569-587)
  • get_emails_by_category (565-567)
  • get_all_emails (561-563)
  • get_email_by_id (248-259)
  • get_db (665-672)
server/python_backend/email_routes.py (2)
  • create_email (95-149)
  • update_email (153-187)
server/python_backend/ai_engine.py (2)
  • analyze_email (97-119)
  • to_dict (35-49)
server/python_nlp/smart_filters.py (1)
  • apply_filters_to_email_data (1253-1293)
server/python_backend/tests/test_filter_routes.py (3)
server/python_nlp/smart_filters.py (4)
  • EmailFilter (16-29)
  • add_custom_filter (579-600)
  • create_intelligent_filters (312-328)
  • prune_ineffective_filters (602-684)
server/python_backend/database.py (2)
  • get_recent_emails (590-593)
  • get_db (665-672)
server/python_backend/tests/test_email_routes.py (1)
  • client (62-66)
server/python_backend/tests/test_action_routes.py (2)
server/python_backend/models.py (1)
  • ActionItem (135-140)
server/python_backend/ai_engine.py (1)
  • analyze_email (97-119)
server/aiRoutes.test.ts (2)
server/python-bridge.ts (2)
  • MappedNLPResult (30-30)
  • pythonNLP (303-303)
server/storage.ts (1)
  • storage (304-304)
server/categoryRoutes.test.ts (1)
server/storage.ts (1)
  • storage (304-304)
server/gmailRoutes.test.ts (1)
server/gmail-ai-service.ts (1)
  • gmailAIService (403-403)
server/aiRoutes.ts (3)
server/python-bridge.ts (2)
  • pythonNLP (303-303)
  • MappedNLPResult (30-30)
server/storage.ts (1)
  • storage (304-304)
shared/schema.ts (1)
  • categories (11-17)
🪛 Pylint (3.3.7)
server/python_nlp/analysis_components/urgency_model.py

[refactor] 7-7: Too few public methods (1/2)

(R0903)

server/python_nlp/analysis_components/sentiment_model.py

[refactor] 16-16: Too few public methods (1/2)

(R0903)

server/python_nlp/analysis_components/topic_model.py

[refactor] 7-7: Too few public methods (1/2)

(R0903)

server/python_nlp/analysis_components/intent_model.py

[refactor] 7-7: Too few public methods (1/2)

(R0903)

server/python_nlp/tests/analysis_components/test_intent_model.py

[error] 57-57: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_intent_model, line 57)'

(E0001)

server/python_nlp/tests/analysis_components/test_topic_model.py

[error] 57-57: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_topic_model, line 57)'

(E0001)

server/python_backend/models.py

[refactor] 131-131: Too few public methods (0/2)

(R0903)


[refactor] 135-135: Too few public methods (0/2)

(R0903)

server/python_backend/tests/test_category_routes.py

[error] 78-78: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_category_routes, line 78)'

(E0001)

server/python_backend/tests/test_dashboard_routes.py

[error] 115-115: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_dashboard_routes, line 115)'

(E0001)

server/python_backend/tests/test_ai_engine.py

[error] 133-133: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_ai_engine, line 133)'

(E0001)

server/python_nlp/tests/analysis_components/test_sentiment_model.py

[error] 100-100: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_sentiment_model, line 100)'

(E0001)

server/python_nlp/tests/analysis_components/test_urgency_model.py

[error] 67-67: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_urgency_model, line 67)'

(E0001)

server/python_backend/tests/test_gmail_routes.py

[error] 111-111: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_gmail_routes, line 111)'

(E0001)

server/python_backend/tests/test_email_routes.py

[error] 169-169: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_email_routes, line 169)'

(E0001)

server/python_backend/tests/test_filter_routes.py

[error] 118-118: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_filter_routes, line 118)'

(E0001)

server/python_backend/tests/test_action_routes.py

[error] 85-85: Parsing failed: 'invalid syntax. Perhaps you forgot a comma? (test_action_routes, line 85)'

(E0001)

server/python_nlp/gmail_service.py

[error] 377-377: Parsing failed: ''{' was never closed (gmail_service, line 377)'

(E0001)

🪛 Ruff (0.11.9)
server/python_nlp/tests/analysis_components/test_intent_model.py

57-57: SyntaxError: Expected ',', found name


57-57: SyntaxError: Expected ',', found name

server/python_nlp/tests/analysis_components/test_topic_model.py

57-57: SyntaxError: Expected ',', found name


57-57: SyntaxError: Expected ',', found name

server/python_backend/category_routes.py

17-17: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


32-32: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


42-42: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


49-49: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


65-65: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


75-75: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

server/python_backend/tests/test_category_routes.py

78-78: SyntaxError: Expected ',', found name


78-78: SyntaxError: Expected ',', found name

server/python_backend/tests/test_dashboard_routes.py

115-115: SyntaxError: Expected ',', found name


115-115: SyntaxError: Expected ',', found name

server/python_backend/action_routes.py

57-57: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

server/python_backend/tests/test_ai_engine.py

133-133: SyntaxError: Expected ',', found name


133-133: SyntaxError: Expected ',', found name

server/python_backend/dashboard_routes.py

16-16: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


37-37: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


47-47: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


64-64: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

server/python_nlp/tests/analysis_components/test_sentiment_model.py

100-100: SyntaxError: Expected ',', found name


100-100: SyntaxError: Expected ',', found name

server/python_nlp/tests/analysis_components/test_urgency_model.py

67-67: SyntaxError: Expected ',', found name


67-67: SyntaxError: Expected ',', found name

server/python_backend/tests/test_gmail_routes.py

111-111: SyntaxError: Expected ',', found name


111-111: SyntaxError: Expected ',', found name

server/python_backend/tests/test_email_routes.py

169-169: SyntaxError: Expected ',', found name


169-169: SyntaxError: Expected ',', found name

server/python_backend/tests/test_filter_routes.py

118-118: SyntaxError: Expected ',', found name


118-118: SyntaxError: Expected ',', found name

server/python_backend/tests/test_action_routes.py

85-85: SyntaxError: Expected ',', found name


85-85: SyntaxError: Expected ',', found name

server/python_backend/email_routes.py

26-26: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


48-48: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


58-58: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


62-62: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


81-81: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


91-91: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


99-99: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


139-139: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


149-149: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


157-157: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


177-177: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


187-187: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

server/python_backend/ai_engine.py

70-70: Undefined name DatabaseManager

(F821)


97-97: Undefined name DatabaseManager

(F821)

server/python_backend/filter_routes.py

2-2: typing.List imported but unused

Remove unused import

(F401)


2-2: typing.Dict imported but unused

Remove unused import

(F401)


2-2: typing.Any imported but unused

Remove unused import

(F401)


38-38: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


65-65: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


69-69: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


99-99: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


109-109: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


129-129: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

server/python_backend/gmail_routes.py

2-2: typing.List imported but unused

Remove unused import

(F401)


2-2: typing.Dict imported but unused

Remove unused import

(F401)


2-2: typing.Any imported but unused

Remove unused import

(F401)


84-84: Do not use bare except

(E722)


109-109: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


119-119: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


136-136: Do not use bare except

(E722)


161-161: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


171-171: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


189-189: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


207-207: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

🪛 Biome (1.9.4)
server/dashboardRoutes.test.ts

[error] 73-73: expected , but instead found of

Remove of

(parse)


[error] 73-73: expected , but instead found server

Remove server

(parse)

server/emailRoutes.test.ts

[error] 260-260: expected , but instead found of

Remove of

(parse)


[error] 260-260: expected , but instead found server

Remove server

(parse)

server/activityRoutes.test.ts

[error] 103-103: expected , but instead found of

Remove of

(parse)


[error] 103-103: expected , but instead found server

Remove server

(parse)

server/aiRoutes.test.ts

[error] 217-217: expected , but instead found of

Remove of

(parse)


[error] 217-217: expected , but instead found server

Remove server

(parse)

server/categoryRoutes.test.ts

[error] 149-149: expected , but instead found of

Remove of

(parse)


[error] 149-149: expected , but instead found server

Remove server

(parse)

server/gmailRoutes.test.ts

[error] 168-168: expected , but instead found of

Remove of

(parse)


[error] 168-168: expected , but instead found server

Remove server

(parse)

server/aiRoutes.ts

[error] 46-46: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🪛 GitHub Check: CodeQL
server/python_backend/dashboard_routes.py

[warning] 54-54: Information exposure through an exception
Stack trace information flows to this location and may be exposed to an external user.

🔇 Additional comments (11)
server/python_nlp/analysis_components/topic_model.py (1)

7-7: Rename aligns with naming conventions
The class has been correctly renamed from TopicAnalyzer to TopicModel, matching other components. Ensure all imports and references (e.g., in nlp_engine.py) are updated accordingly.

server/python_nlp/analysis_components/intent_model.py (1)

7-7: Consistent renaming to IntentModel
The class rename is in line with the updated analyzer-to-model convention. Verify that NLPEngine instantiation and all imports are updated to use IntentModel.

server/python_nlp/analysis_components/sentiment_model.py (1)

16-16: Class rename to SentimentModel is correct
The rename maintains consistency with other model components. Confirm that tests and nlp_engine.py import SentimentModel instead of the old name.

server/python_nlp/analysis_components/urgency_model.py (1)

7-7: Analyzer-to-Model rename applied correctly
UrgencyAnalyzerUrgencyModel is consistent with the other components. Ensure downstream code uses UrgencyModel.

server/ai-engine.ts (1)

15-15: Added categoryId to schema—verify usage
You added categoryId as optional in aiAnalysisSchema, but neither LocalNLPModel nor HuggingFaceModel populate this field. Confirm that your Python bridge or other data mappers supply categoryId, or update the TS models to propagate it.

Run:

rg "categoryId" -n server

to locate where this property must be mapped in your codebase.

server/python-bridge.ts (2)

27-27: LGTM! Proper implementation of category ID mapping.

The optional category_id field and its mapping to categoryId correctly follow the snake_case to camelCase conversion pattern used throughout this file.

Also applies to: 57-57


30-30: Verify that the AIAnalysis type includes categoryId.

The comment suggests that AIAnalysis now includes categoryId, but this should be verified against the actual type definition.

#!/bin/bash
# Description: Verify that AIAnalysis type includes categoryId field

# Search for the aiAnalysisSchema definition to confirm categoryId is included
ast-grep --pattern 'const aiAnalysisSchema = z.object({
  $$$
})'

# Also search for any direct references to categoryId in the schema
rg -A 5 -B 5 "aiAnalysisSchema.*categoryId|categoryId.*aiAnalysisSchema" 
server/routes.ts (1)

3-9: Excellent modularization of routes!

The refactoring successfully separates route logic into dedicated modules, improving code organization and maintainability. The mounting pattern follows Express best practices.

Also applies to: 22-28

server/python_nlp/tests/analysis_components/test_topic_model.py (1)

1-56: Well-structured test suite with comprehensive coverage!

The tests properly mock the sklearn model and cover all major scenarios including model success, failure with fallback, and keyword-based analysis. Good use of assertions to verify the expected behavior.

server/python_nlp/tests/analysis_components/test_urgency_model.py (1)

1-44: 👍 Comprehensive coverage

The tests exercise both the ML and fallback paths and correctly mock model behaviour. Nice use of logging.disable to keep the output clean.

server/python_backend/action_routes.py (1)

47-57: Preserve original traceback when re-raising

When you wrap an exception you lose the causal chain. Pass the original exception with from e:

-        raise HTTPException(status_code=500, detail=f"Failed to extract action items: {str(e)}")
+        raise HTTPException(
+            status_code=500,
+            detail=f"Failed to extract action items: {e}"
+        ) from e

[ suggest_nitpick ]

Originally posted by @coderabbitai[bot] in #69 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions