Skip to content

Conversation

@smokeyScraper
Copy link
Contributor

@smokeyScraper smokeyScraper commented Oct 24, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved Discord bot and WebSocket connection stability via updated heartbeat and keep-alive settings.
    • More precise error responses for integration update/delete flows: not-found yields 404, bad-request yields 400.
  • Chores

    • Updated and added server and library dependencies for compatibility and stability.
    • Adjusted model initialization to better support attribute-based data sources.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

Introduces a new IntegrationNotFoundError in the integration service and updates API handlers to catch it; maps ValueError to 400 in some paths; adds Pydantic v2 model_config to IndexedRepository; adds WebSocket keep-alive params to server start; adjusts Discord bot heartbeat and updates multiple dependencies and subproject pyproject.

Changes

Cohort / File(s) Summary
Integration service & API
backend/app/services/integration_service.py, backend/app/api/v1/integrations.py
Added IntegrationNotFoundError export; update_integration now raises IntegrationNotFoundError for missing items; delete_integration pre-check raises IntegrationNotFoundError/ValueError for missing items; API handlers updated to catch IntegrationNotFoundError and ValueError, preserving existing HTTPException handling and mapping ValueError -> 400.
Pydantic model migration
backend/app/models/database/supabase.py
Added ConfigDict import and model_config = ConfigDict(from_attributes=True) to IndexedRepository for Pydantic v2 attribute-based initialization.
WebSocket keep-alive / startup scripts
backend/main.py, backend/start_github_mcp_server.py
Added ws_ping_interval=20 and ws_ping_timeout=20 to uvicorn.run; startup script now calls sys.exit(1) on ImportError or general exceptions.
Discord bot config
backend/integrations/discord/bot.py
Passed heartbeat_timeout=60.0 into Discord bot super().__init__.
Top-level dependency updates
pyproject.toml, backend/requirements.txt
Bumped uvicorn and discord-py ranges; added/relaxed websockets constraint; updated py-cord and other dependency adjustments.
Code-graph-backend subproject deps & Python range
backend/app/database/falkor/code-graph-backend/pyproject.toml
Tightened Python requirement to >=3.10,<3.14; updated graphrag-sdk; added multiple new dependencies (tree-sitter-*, flask, python-dotenv, multilspy, javatools, pygit2, toml).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant API as integrations API
  participant Service as integration_service
  participant DB as persistence

  API->>Service: update_integration(id, data)
  Service->>DB: fetch integration
  alt exists
    DB-->>Service: integration
    Service->>DB: update & save
    DB-->>Service: success
    Service-->>API: return updated integration
  else not found
    Service-->>API: raise IntegrationNotFoundError
    Note right of API #ffeead: API catches IntegrationNotFoundError -> HTTP 404
  end
Loading
sequenceDiagram
  autonumber
  participant API as integrations API
  participant Service as integration_service
  participant DB as persistence

  API->>Service: delete_integration(id)
  Service->>DB: fetch integration (pre-check)
  alt found
    DB-->>Service: integration
    Service->>DB: delete
    DB-->>Service: success
    Service-->>API: success response
  else not found
    Service-->>API: raise ValueError (or IntegrationNotFoundError)
    Note right of API #ffd6d6: API maps ValueError -> HTTP 400 (and IntegrationNotFoundError -> 404)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through code at dawn,
Heartbeats lengthened, pings drawn,
Not-found names now called anew,
Pydantic v2 fits like glue,
Dependencies nudged — onward we spawn.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "fix: deprecation warnings and bug fixes" refers to real aspects present in the changeset—the py-cord dependency was indeed updated with an explicit comment about minimizing deprecation warnings, and multiple improvements and error handling changes are included. However, the term "bug fixes" is highly generic and non-descriptive, failing to convey what specific bugs are being fixed or what the primary changes are. A developer scanning the history would not clearly understand the main objectives from this title, which spans error handling improvements, WebSocket configuration changes, ORM modernization, and multiple dependency updates. The vagueness of "bug fixes" makes it difficult to grasp the changeset's actual scope and intent. Consider revising the title to be more specific about the primary changes, such as "fix: improve error handling and add websocket keepalive configuration" or "fix: update dependencies and improve integration error handling." This would give reviewers and future developers a clearer picture of what the changeset addresses without requiring them to review the full diff.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
pyproject.toml (1)

42-42: Websockets version added, but conflicts with requirements.txt.

This adds websockets >=15.0.1,<16.0.0, but backend/requirements.txt (line 227) specifies >=14.2,<15.0. This version mismatch was already flagged in the requirements.txt review and needs to be resolved for consistent dependency resolution.

backend/app/api/v1/integrations.py (1)

97-98: Same ValueError issues as in update_integration.

This endpoint has the same problems identified in lines 79-80:

  • Using ValueError for "not found" is semantically incorrect
  • Broad catching of all ValueError exceptions may incorrectly map validation errors (400) to 404 errors

Additionally, note the inconsistency with get_integration (lines 60-64), which checks for None and raises 404 directly, rather than catching an exception. This inconsistency makes the codebase harder to understand and maintain.

Consider applying the same fix as suggested for update_integration.

🧹 Nitpick comments (1)
backend/app/database/falkor/code-graph-backend/pyproject.toml (1)

10-23: LGTM! Dependency updates and additions for enhanced code analysis.

The Python version range update to >=3.10,<3.14 is more explicit and includes Python 3.13. The addition of tree-sitter language parsers (C, Python, Java), Flask, and related dependencies appears to expand the code analysis capabilities of the code-graph-backend.

Note: The multilspy dependency uses a git source (git+https://github.com/AviAvni/multilspy.git@python-init-params), which could be fragile if the branch is rebased or deleted. Consider pinning to a specific commit SHA for reproducibility.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa57ec and b6ca636.

⛔ Files ignored due to path filters (2)
  • backend/app/database/falkor/code-graph-backend/poetry.lock is excluded by !**/*.lock
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • backend/app/api/v1/integrations.py (3 hunks)
  • backend/app/database/falkor/code-graph-backend/pyproject.toml (1 hunks)
  • backend/app/models/database/supabase.py (2 hunks)
  • backend/app/services/integration_service.py (2 hunks)
  • backend/integrations/discord/bot.py (1 hunks)
  • backend/main.py (1 hunks)
  • backend/requirements.txt (2 hunks)
  • backend/start_github_mcp_server.py (1 hunks)
  • pyproject.toml (2 hunks)
🧰 Additional context used
🪛 Ruff (0.14.1)
backend/app/services/integration_service.py

145-145: Abstract raise to an inner function

(TRY301)


145-145: Avoid specifying long messages outside the exception class

(TRY003)

backend/start_github_mcp_server.py

20-20: Possible binding to all interfaces

(S104)

🔇 Additional comments (11)
backend/integrations/discord/bot.py (1)

20-25: LGTM! WebSocket keep-alive configuration added.

The heartbeat_timeout=60.0 parameter properly configures the Discord gateway heartbeat timeout, which should help maintain stable WebSocket connections and align with the broader WebSocket keep-alive improvements made throughout this PR.

backend/requirements.txt (1)

156-156: LGTM! Dependency update to address deprecation warnings.

The py-cord version bump from 2.6.1 to 2.6.2 aligns with the PR objective of minimizing deprecation warnings.

backend/app/models/database/supabase.py (2)

1-1: LGTM! Pydantic v2 import added.

The ConfigDict import is correctly added to support Pydantic v2 configuration syntax.


228-228: Remove the suggestion about adding from_attributes=True to other models—it's not needed for this codebase.

The from_attributes=True configuration is designed for Pydantic models instantiated from ORM objects with attribute access. However, the codebase instantiates all models via dictionary unpacking (Model(**result.data[0])), where Supabase REST API returns plain dictionaries. This pattern does not require from_attributes=True. The configuration on IndexedRepository appears unnecessary or intended for future use; it provides no benefit for current instantiation patterns. No other models need this change.

Likely an incorrect or invalid review comment.

backend/start_github_mcp_server.py (2)

20-20: LGTM! WebSocket keep-alive configuration added.

The ws_ping_interval=20 and ws_ping_timeout=20 parameters properly configure WebSocket keep-alive, which should help maintain stable connections. These values are consistent with the configuration in backend/main.py.

Note: The static analysis hint about binding to all interfaces (0.0.0.0) is flagged but is likely acceptable for this server. If this service is exposed to untrusted networks, consider binding to 127.0.0.1 instead.


25-28: LGTM! Explicit exit codes added.

The sys.exit(1) calls in exception handlers make error handling more explicit and ensure the process exits with a failure code when startup fails.

backend/main.py (1)

140-147: LGTM! WebSocket keep-alive configuration added.

The ws_ping_interval=20 and ws_ping_timeout=20 parameters are correctly added to the uvicorn configuration. This matches the configuration in backend/start_github_mcp_server.py, ensuring consistency across server startup scripts.

backend/app/services/integration_service.py (1)

10-10: LGTM! Removed unused import.

The NotFoundError import has been correctly removed as it's no longer used in this module.

pyproject.toml (2)

29-29: LGTM! Discord-py version updated.

The discord-py version bump to >=2.6.4,<3.0.0 aligns with the py-cord 2.6.2 update in requirements.txt and should help address deprecation warnings.


26-26: Verification complete: uvicorn 0.38 supports ws_ping_interval and ws_ping_timeout parameters.

Uvicorn 0.38 exposes both ws_ping_interval and ws_ping_timeout as CLI flags and Config options, confirming compatibility with the WebSocket configuration used in the codebase. The version bump is safe to proceed.

backend/app/api/v1/integrations.py (1)

10-10: Import change is consistent with service layer refactoring.

The removal of NotFoundError aligns with the service layer change. However, see comments below regarding semantic concerns with the new exception handling approach.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6ca636 and 92ea480.

📒 Files selected for processing (3)
  • backend/app/api/v1/integrations.py (3 hunks)
  • backend/app/services/integration_service.py (3 hunks)
  • backend/requirements.txt (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/requirements.txt
🧰 Additional context used
🧬 Code graph analysis (2)
backend/app/services/integration_service.py (2)
backend/app/models/integration.py (1)
  • IntegrationStatusResponse (44-49)
backend/app/api/v1/integrations.py (1)
  • get_integration (52-68)
backend/app/api/v1/integrations.py (1)
backend/app/services/integration_service.py (1)
  • IntegrationNotFoundError (16-18)
🪛 Ruff (0.14.1)
backend/app/services/integration_service.py

150-150: Abstract raise to an inner function

(TRY301)


150-150: Avoid specifying long messages outside the exception class

(TRY003)


180-180: Abstract raise to an inner function

(TRY301)


180-180: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (4)
backend/app/services/integration_service.py (2)

16-18: Excellent addition for semantic clarity.

The custom IntegrationNotFoundError exception properly addresses the semantic concerns from previous reviews about using ValueError for "not found" scenarios. This follows Python best practices for domain-specific exceptions.


148-150: Correct use of the new exception type.

The update_integration method now properly raises IntegrationNotFoundError when the integration doesn't exist, which is semantically correct and improves code clarity.

backend/app/api/v1/integrations.py (2)

10-10: Import updated correctly.

The import statement correctly reflects the new IntegrationNotFoundError exception from the service layer.


79-82: Exception handling properly distinguishes error types.

The exception handling correctly separates "not found" errors (404) from validation errors (400), providing clear semantic distinction. The exception order is also correct, catching from most specific to least specific.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
backend/app/services/integration_service.py (1)

150-150: Consider refactoring error messages per Ruff suggestions.

Static analysis suggests abstracting the repeated "Integration not found" message. While the current implementation is acceptable, you could reduce duplication by defining the message as a class constant if you expect to extend error messaging in the future:

 class IntegrationNotFoundError(Exception):
     """Raised when an integration is not found."""
-    pass
+    DEFAULT_MESSAGE = "Integration not found"
+    
+    def __init__(self, message: str = None):
+        super().__init__(message or self.DEFAULT_MESSAGE)

Then simplify the raise statements:

raise IntegrationNotFoundError()

This addresses Ruff hints TRY003 and TRY301, though it's optional for your current use case.

Also applies to: 180-180

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92ea480 and 78c0318.

📒 Files selected for processing (3)
  • backend/app/api/v1/integrations.py (3 hunks)
  • backend/app/services/integration_service.py (3 hunks)
  • backend/requirements.txt (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
backend/app/services/integration_service.py (2)
backend/app/models/integration.py (1)
  • IntegrationStatusResponse (44-49)
backend/app/api/v1/integrations.py (1)
  • get_integration (52-68)
backend/app/api/v1/integrations.py (1)
backend/app/services/integration_service.py (1)
  • IntegrationNotFoundError (16-18)
🪛 Ruff (0.14.1)
backend/app/services/integration_service.py

150-150: Abstract raise to an inner function

(TRY301)


150-150: Avoid specifying long messages outside the exception class

(TRY003)


180-180: Abstract raise to an inner function

(TRY301)


180-180: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (8)
backend/requirements.txt (2)

156-156: LGTM: Patch version update addresses deprecation warnings.

The py-cord update from 2.6.1 to 2.6.2 is a safe patch version bump that aligns with the PR's objective to minimize deprecation warnings.


227-227: LGTM: websockets version now aligned with pyproject.toml.

The websockets version constraint has been updated to match pyproject.toml (>=15.0.1,<16.0.0), resolving the previous version mismatch. This ensures consistent dependency resolution across the project.

backend/app/services/integration_service.py (3)

16-18: LGTM: Custom exception improves semantic clarity.

The introduction of IntegrationNotFoundError provides clear, domain-specific exception handling that distinguishes "not found" scenarios from validation errors. This is a significant improvement over using generic ValueError.


148-150: LGTM: Consistent error handling for not-found scenarios.

The update_integration method now properly raises IntegrationNotFoundError when the integration doesn't exist, providing consistent semantics across the service layer.


177-180: LGTM: Existence check prevents silent failures.

The delete_integration method now validates the integration exists before attempting deletion and raises IntegrationNotFoundError appropriately. This ensures the API layer can return proper 404 responses and addresses the critical issue from the previous review.

backend/app/api/v1/integrations.py (3)

10-10: LGTM: Import updated to match service layer.

The import correctly references IntegrationNotFoundError from the service layer, maintaining consistency across the codebase.


79-82: LGTM: Exception handling properly maps domain errors to HTTP status codes.

The update_integration endpoint now correctly distinguishes between not-found scenarios (404) and validation errors (400), addressing the semantic confusion from the previous review. The exception handling is clear and maintainable.


99-102: LGTM: Consistent exception handling across endpoints.

The delete_integration endpoint uses the same exception handling pattern as update_integration, ensuring consistency. The custom IntegrationNotFoundError provides clear semantics, and ValueError is appropriately mapped to 400 Bad Request.

@smokeyScraper smokeyScraper merged commit a01d7ea into AOSSIE-Org:main Oct 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant