Devr.AI icon indicating copy to clipboard operation
Devr.AI copied to clipboard

fix: bug fixes in backend and frontend integration

Open Aditya30ag opened this issue 1 year ago β€’ 9 comments

Bugs Fixed in Devr.AI Project

This document lists the bugs that have been identified and fixed in the Devr.AI project.

βœ… Fixed Bugs

1. Console.error Statements in Production Code

Severity: Medium
Location: Frontend
Files Affected:

  • frontend/src/App.tsx
  • frontend/src/lib/api.ts
  • frontend/src/components/integration/BotIntegration.tsx

Issue: Console.error statements were left in production code, which can expose sensitive error information in browser console and impact performance.

Fix Applied:

  • Removed console.error from session check in App.tsx
  • Removed console.error from logout handler in App.tsx
  • Removed console.error from API client interceptor in api.ts
  • Removed console.error from healthCheck method in api.ts
  • Removed console.error from BotIntegration.tsx and added proper error handling

Impact: Improved security and performance by removing unnecessary console logging.


2. Missing exc_info in Backend Exception Logging

Severity: Medium
Location: Backend
Files Affected:

  • backend/app/database/weaviate/client.py
  • backend/app/core/orchestration/queue_manager.py

Issue: Exception logging without exc_info=True makes debugging difficult as stack traces are not captured.

Fix Applied:

  • Added exc_info=True to all exception logging statements in Weaviate client
  • Added exc_info=True to RabbitMQ connection error logging

Impact: Better debugging capabilities with full stack traces in logs.


3. Improved Error Handling in BotIntegration

Severity: Low
Location: Frontend
Files Affected:

  • frontend/src/components/integration/BotIntegration.tsx

Issue: Error in loadIntegrationStatus was only logged but didn't reset component state, potentially leaving UI in inconsistent state.

Fix Applied:

  • Added proper state reset (setIsConnected(false), setIntegration(null)) in catch block
  • Removed console.error and added descriptive comment

Impact: More robust error handling and consistent UI state.


Summary by CodeRabbit

  • Refactor

    • Improved error logging to include full tracebacks for better diagnostics.
    • Switched to per-request client lifecycles and tightened exception handling.
  • Bug Fixes / Behavior

    • Messages now persist and are serialized as JSON for more reliable delivery.
    • Authentication now deduplicates 401 handling, prevents redirect loops, and clears sessions reliably.
    • UI integration and logout flows now fail silently while correctly updating visible connection state.
  • New Feature

    • Login now respects and safely validates an encoded return URL before redirecting.

Aditya30ag avatar Oct 27 '25 13:10 Aditya30ag

πŸ“ Walkthrough

Walkthrough

Backend: tightened queue connectivity checks, message serialization to JSON with persistent delivery, and richer exc_info logging; migrated Weaviate client from a module singleton to per-context creation and narrowed exception handling. Frontend: silenced some console.error calls, added deduplicated 401 handling, and implemented validated returnUrl redirects on login.

Changes

Cohort / File(s) Summary
Backend β€” queue manager
backend/app/core/orchestration/queue_manager.py
Added connectivity guard (raise if no/closed channel), serialize priority as string, publish using persistent Message with content-type: application/json, and enable exc_info=True on failure logs.
Backend β€” weaviate client
backend/app/database/weaviate/client.py
Removed module-level cached client; get_client() now returns a per-context weaviate.use_async_with_local() instance; narrowed exception handling to weaviate.exceptions.WeaviateBaseError; updated closing/exception logs to use exc_info=True.
Frontend β€” auth & error handling
frontend/src/App.tsx, frontend/src/lib/api.ts
Silenced console.error in auto-login/logout handlers; added deduplicated async 401 handling with sign-out/redirect and PUBLIC_PATHS bypass; health-check logs limited to DEV; exported apiClient singleton.
Frontend β€” integration & login flow
frontend/src/components/integration/BotIntegration.tsx, frontend/src/components/pages/LoginPage.tsx
BotIntegration catch now silently resets isConnected and clears integration state; LoginPage reads and validates returnUrl query param and conditionally navigates to the decoded internal path.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Producer
    participant QueueMgr
    participant Broker
    Producer->>QueueMgr: enqueue(message, priority)
    alt no channel / channel closed
        QueueMgr-->>Producer: raise ConnectivityError
    else channel available
        QueueMgr->>QueueMgr: serialize priority as string
        QueueMgr->>Broker: publish(Message persistent, content-type=application/json)
        Broker-->>QueueMgr: ack
    end
sequenceDiagram
    autonumber
    actor Worker
    participant QueueMgr
    participant Processor
    Worker->>QueueMgr: poll/receive message
    QueueMgr->>Processor: process(message)
    alt processing error
        Processor-->>QueueMgr: error
        QueueMgr-->>QueueMgr: log error (exc_info=True)
        QueueMgr->>Worker: nack / handle failure
    else success
        Processor-->>QueueMgr: success
        QueueMgr->>Worker: ack
    end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AOSSIE-Org/Devr.AI#79 β€” overlaps edits to frontend/src/App.tsx authentication/login/logout logic.
  • AOSSIE-Org/Devr.AI#134 β€” similar silencing of console.error calls in frontend/src/App.tsx.

Suggested reviewers

  • smokeyScraper
  • chandansgowda

Poem

πŸ‡ I hop through logs both near and far,

Tracebacks gleam like a careful star,
Messages stamped persistent and neat,
Frontend hushes, redirects greet,
A snug little burrow, code complete.

πŸš₯ Pre-merge checks | βœ… 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is overly vague and generic. It uses non-descriptive terms like 'bug fixes' without specifying which bugs or what the main changes accomplish, making it unclear what the primary issue addressed is. Replace with a more specific title that highlights the main change, such as 'fix: improve error logging and state handling in backend and frontend' or focus on the primary fix if one issue dominates.
βœ… Passed checks (1 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 27 '25 13:10 coderabbitai[bot]

could you please review the coderabit suggested changes @Aditya30ag?

smokeyScraper avatar Oct 28 '25 16:10 smokeyScraper

Yaa sure

Aditya30ag avatar Oct 28 '25 19:10 Aditya30ag

@smokeyScraper Done

Aditya30ag avatar Oct 28 '25 20:10 Aditya30ag

hey @Aditya30ag, Thanks for the improvements! The error handling and logging changes are solid. However, the 401 handler implementation has a few issues that need to be addressed before it can be merged.

Issues to Address

  1. returnUrl feature is incomplete You're appending returnUrl to the login redirect, but LoginPage.tsx doesn't read or use this parameter. Users won't actually be redirected back to their original page after login. Please either: Add logic to LoginPage.tsx to read returnUrl from query params and redirect after successful login, OR Remove the returnUrl logic from this PR and we can tackle it as a separate feature

  2. Path check will break other public pages if (!window.location.pathname.includes('/login')) This misses our other public routes. If a 401 happens on /forgot-password, /reset-password, or /signup, users will get incorrectly yanked to the login page mid-flow.

  3. Race condition with multiple 401s On page load, multiple components often fire API requests simultaneously. If they all return 401, the current code will call signOut() and trigger redirects multiple times.

smokeyScraper avatar Dec 27 '25 18:12 smokeyScraper

Could you please make these changes @Aditya30ag ? Rest, the PR seems ready to be merged.

smokeyScraper avatar Dec 27 '25 18:12 smokeyScraper

@smokeyScraper yeah sure i will do the changes

Aditya30ag avatar Dec 28 '25 04:12 Aditya30ag

Please have a look done the requested changes

Aditya30ag avatar Dec 28 '25 04:12 Aditya30ag

@Zahnentferner please have a look into this

Aditya30ag avatar Feb 17 '26 13:02 Aditya30ag