Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Fix exception response on RPC error & Missing Graph Running Status #9529

Merged
merged 4 commits into from
Feb 26, 2025

Conversation

majdyz
Copy link
Contributor

@majdyz majdyz commented Feb 26, 2025

HttpResponse error introduced by RPC is buggy since we are returning the exception as is instead of the string version of it.
Also RUNNING status on the graph execution is missing.

Changes 🏗️

  • Refactored & fixed the exception return handling on RPC failure.
  • Add RUNNING status update during the graph execution.

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • ...
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.example is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

@majdyz majdyz requested a review from Pwuts February 26, 2025 17:16
@majdyz majdyz requested a review from a team as a code owner February 26, 2025 17:16
@majdyz majdyz requested review from kcze and removed request for a team February 26, 2025 17:16
@github-actions github-actions bot added the platform/backend AutoGPT Platform - Back end label Feb 26, 2025
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 Security concerns

Error Information Exposure:
The error handler returns the raw exception message to the client (line 250). This could potentially expose sensitive implementation details or stack traces. Consider sanitizing or limiting the error information sent to clients.

⚡ Recommended focus areas for review

Error Handling

The new error handling approach removes try-catch blocks from endpoints but doesn't preserve the original error message context (function name). Consider if this context would be useful for debugging.

    async def async_endpoint(body: RequestBodyModel):  # type: ignore #RequestBodyModel being variable
        return await f(
            **{name: getattr(body, name) for name in body.model_fields}
        )

    return async_endpoint
else:

    def sync_endpoint(body: RequestBodyModel):  # type: ignore #RequestBodyModel being variable
        return f(**{name: getattr(body, name) for name in body.model_fields})
Exception Types

The error handler only explicitly handles ValueError (400) and generic Exception (500). Consider if other specific exception types need custom status codes.

self.fastapi_app.add_exception_handler(
    ValueError, self._handle_internal_http_error(400)
)
self.fastapi_app.add_exception_handler(
    Exception, self._handle_internal_http_error(500)
)

Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit 82727f4
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/67bf5507a44ec00008ff070e

Copy link

deepsource-io bot commented Feb 26, 2025

Here's the code health analysis summary for commits 5f5d30a..82727f4. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗
DeepSource Python LogoPython✅ Success
❗ 42 occurences introduced
🎯 39 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 82727f4
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/67bf5507783e32000894a7ac

@majdyz majdyz changed the title fix(backend): Fix exception response on RPC error fix(backend): Fix exception response on RPC error & Missing Graph Running Status Feb 26, 2025
@majdyz majdyz enabled auto-merge February 26, 2025 17:30
@majdyz majdyz added this pull request to the merge queue Feb 26, 2025
Merged via the queue into dev with commit 538ad06 Feb 26, 2025
23 checks passed
@majdyz majdyz deleted the zamilmajdy/fix-error-http-response branch February 26, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants