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

feat(platform): Add Dispute & Refund resolution process #9466

Merged
merged 17 commits into from
Feb 18, 2025

Conversation

majdyz
Copy link
Contributor

@majdyz majdyz commented Feb 11, 2025

Changes 🏗️

Added the dispute & refund handling on the system.

Screen.Recording.Feb.11.2025.Video.Speed.mp4

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 kcze February 11, 2025 12:51
@majdyz majdyz requested a review from a team as a code owner February 11, 2025 12:51
@majdyz majdyz requested review from Pwuts and removed request for a team February 11, 2025 12:51
Copy link

netlify bot commented Feb 11, 2025

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

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

@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end size/xl labels Feb 11, 2025
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Sensitive information exposure:
The dispute evidence text includes detailed transaction history and user email which is sent to Stripe. While Stripe is a trusted provider, consider minimizing the exposed information to only what's necessary for dispute resolution.

⚡ Recommended focus areas for review

Error Handling

The refund amount validation logic may allow invalid refund amounts. The code should validate that the refund amount is positive and less than or equal to both the original transaction amount and current balance.

if request.amount <= 0 or request.amount > transaction.amount:
    raise AssertionError(
        f"Invalid amount to deduct ${request.amount/100} from ${transaction.amount/100} top-up"
    )
Race Condition

The dispute handling logic checks balance and makes decisions without proper transaction isolation. This could lead to race conditions if multiple disputes are processed simultaneously.

if balance >= transaction.amount:
    logger.warning(f"Accepting dispute from {user_id} for ${amount/100}")
    dispute.close()
    return
Data Truncation

The dispute evidence text is truncated to 20000 characters without warning. This could silently drop important transaction history information.

"uncategorized_text": evidence_text[:20000],

Copy link

deepsource-io bot commented Feb 11, 2025

Here's the code health analysis summary for commits 0117006..ee2a92b. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 48 occurences introduced
🎯 31 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ Success
❗ 12 occurences introduced
🎯 8 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 11, 2025

Deploy Preview for auto-gpt-docs canceled.

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

@majdyz majdyz requested review from itsababseh and removed request for itsababseh February 13, 2025 12:03
@majdyz majdyz requested review from itsababseh and removed request for itsababseh February 13, 2025 12:03
Copy link

@itsababseh itsababseh left a comment

Choose a reason for hiding this comment

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

Looks good to me, great job! Thanks for attaching the video. The CI passed let me know if you need me to approve this if someone else already checked the code.

Quick question @majdyz is there a reason a user has to click the refresh on balance before the changes happen?

@majdyz
Copy link
Contributor Author

majdyz commented Feb 14, 2025

@itsababseh thanks! @kcze will review the code part so it's fine :)

Quick question @majdyz is there a reason a user has to click the refresh on balance before the changes happen?

We just don't know how fast the refund is processed by the payment processor, so we might sometimes get a delay when the user needs to manually refresh the balance. It's the same reason why the refresh balance button is there in the first place.

We can fix this holistically by having a more proactive balance check or server sent events containing balance updates, but this is outside the scope of this PR and more general product improvement.

…milmajdy/secrt-1023-automatic-dispute-resolution
@majdyz majdyz requested a review from kcze February 14, 2025 12:21
@majdyz majdyz enabled auto-merge February 18, 2025 09:00
@majdyz majdyz added this pull request to the merge queue Feb 18, 2025
Merged via the queue into dev with commit 43460b8 Feb 18, 2025
27 checks passed
@majdyz majdyz deleted the zamilmajdy/secrt-1023-automatic-dispute-resolution branch February 18, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort [1-5]: 4 size/xl
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants