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

[SLT-158] fix(opbot): fixed message #3201

Closed
wants to merge 3 commits into from
Closed

Conversation

golangisfun123
Copy link
Collaborator

@golangisfun123 golangisfun123 commented Sep 26, 2024

was returning prematurely on transactions that had not been confirmed yet

Summary by CodeRabbit

  • New Features

    • Enhanced error messaging for refund submissions to improve user clarity.
    • Updated success response to include a transaction link for better tracking.
  • Bug Fixes

    • Refined logic for checking refund status to ensure accurate feedback to users.
    • Adjusted retry mechanism for refund submissions to streamline the process.

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes in the rfqRefund function primarily focus on enhancing error handling and response messaging. Key modifications include improved user notifications for refund submission failures, refined logic for checking refund status, adjustments to the retry mechanism, and updated response messages that provide clearer information regarding the transaction status.

Changes

File Path Change Summary
contrib/opbot/botmd/commands.go Modified rfqRefund function to improve error handling, refine refund status checks, adjust retry logic, and update user response messages.

Possibly related PRs

Suggested labels

go, size/xs

Suggested reviewers

  • trajan0x

🐇 In the garden of code, we hop with glee,
Fixing errors and flows, as happy as can be.
With messages clear, and retries in sight,
Our refunds now sparkle, oh what a delight!
So let’s celebrate changes, both big and small,
For in this code garden, we flourish for all! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Sep 26, 2024
Copy link

cloudflare-workers-and-pages bot commented Sep 26, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: a48be5e
Status: ✅  Deploy successful!
Preview URL: https://09793cca.sanguine-fe.pages.dev
Branch Preview URL: https://opbot-message.sanguine-fe.pages.dev

View logs

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 257e57c and a48be5e.

📒 Files selected for processing (1)
  • contrib/opbot/botmd/commands.go (2 hunks)
🔇 Additional comments (1)
contrib/opbot/botmd/commands.go (1)

367-368: Verify the reduced retry parameters

The maximum attempt time has been reduced from 30 seconds to 15 seconds, and the maximum attempts from 5 to 3. Please verify that these settings are sufficient to allow the refund confirmation process to complete successfully and won't cause premature termination of the retries.

Comment on lines +362 to +363
b.logger.Errorf(ctx, "refund not confirmed yet")
return errors.New("refund not confirmed yet")
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use appropriate log level for expected retries

The message "refund not confirmed yet" is logged as an error. Since this might be a normal condition during retries, consider using a lower log level like Infof or Debugf to prevent cluttering the error logs.

Suggested change:

-	b.logger.Errorf(ctx, "refund not confirmed yet")
+	b.logger.Infof(ctx, "refund not confirmed yet")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
b.logger.Errorf(ctx, "refund not confirmed yet")
return errors.New("refund not confirmed yet")
b.logger.Infof(ctx, "refund not confirmed yet")
return errors.New("refund not confirmed yet")

Comment on lines +372 to 374
_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
log.Printf("error fetching quote request: %v\n", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Check for errors before logging and correct log message

The log message "error fetching quote request" does not match the context, as this section handles refund submission. Additionally, err should be checked before logging to avoid logging nil errors.

Suggested fix:

_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
-if err != nil {
-    log.Printf("error fetching quote request: %v\n", err)
+if err != nil {
    log.Printf("error sending refund confirmation: %v\n", err)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
log.Printf("error fetching quote request: %v\n", err)
return
_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
if err != nil {
log.Printf("error sending refund confirmation: %v\n", err)
}
return

Comment on lines +347 to 349
_, err := ctx.Response().Reply("error submitting refund")
log.Printf("error submitting refund: %v\n", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Check for errors before logging

After sending the reply with ctx.Response().Reply, the code logs an error without checking if err != nil. This could lead to unnecessary logging when there is no error. Please check the error before logging.

Suggested fix:

_, err := ctx.Response().Reply("error submitting refund")
-if err != nil {
+if err != nil {
	log.Printf("error submitting refund: %v\n", err)
+}

Committable suggestion was skipped due to low confidence.

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 37.88710%. Comparing base (3e75b0d) to head (a48be5e).
Report is 154 commits behind head on master.

Files with missing lines Patch % Lines
contrib/opbot/botmd/commands.go 0.00000% 12 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3201         +/-   ##
===================================================
- Coverage   39.46606%   37.88710%   -1.57897%     
===================================================
  Files            479         418         -61     
  Lines          26932       24251       -2681     
  Branches         342          82        -260     
===================================================
- Hits           10629        9188       -1441     
+ Misses         15557       14320       -1237     
+ Partials         746         743          -3     
Flag Coverage Δ
opbot 0.48691% <0.00000%> (-0.00180%) ⬇️
promexporter ?
solidity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@golangisfun123 golangisfun123 changed the title fix(opbot): fixed message [SLT-156] fix(opbot): fixed message Sep 27, 2024
@golangisfun123 golangisfun123 changed the title [SLT-156] fix(opbot): fixed message [SLT-158] fix(opbot): fixed message Sep 27, 2024
Copy link

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Oct 12, 2024
@github-actions github-actions bot closed this Oct 17, 2024
@github-actions github-actions bot deleted the opbot-message branch December 29, 2024 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/xs Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant