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

chore(auction): return error on Not Found auction ID #2544

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Jun 7, 2024

Description

Summary by CodeRabbit

  • Refactor
    • Improved error handling in the auction rewards and bids functionality to ensure more reliable operations.

@robert-zaremba robert-zaremba added the skip-e2e-test Skip the e2e tests label Jun 7, 2024
@robert-zaremba robert-zaremba requested a review from a team as a code owner June 7, 2024 16:49
Copy link
Contributor

coderabbitai bot commented Jun 7, 2024

Walkthrough

The recent changes in the x/auction/keeper/grpc_query.go file involve enhancing the error handling in the RewardsAuction function. Specifically, the function now checks for nil rewards and returns an appropriate error if rewards are not found. Additionally, necessary imports for gRPC status codes and error handling have been added to support these improvements.

Changes

Files Change Summary
x/auction/keeper/grpc_query.go Added imports for gRPC status codes and refactored RewardsAuction function to handle nil rewards and return errors if rewards are not found.

Poem

In the code where auctions play,
Rewards and bids now find their way.
With gRPC's guiding light,
Errors handled, clear and bright.
A rabbit's joy in every line,
Making auctions run just fine. 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

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

Project coverage is 62.76%. Comparing base (7f05ad4) to head (69f9877).
Report is 494 commits behind head on main.

Current head 69f9877 differs from pull request most recent head fde43f9

Please upload reports for the commit fde43f9 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2544       +/-   ##
===========================================
- Coverage   75.38%   62.76%   -12.63%     
===========================================
  Files         100      275      +175     
  Lines        8025    15946     +7921     
===========================================
+ Hits         6050    10009     +3959     
- Misses       1589     5163     +3574     
- Partials      386      774      +388     
Files Coverage Δ
x/auction/keeper/grpc_query.go 0.00% <0.00%> (ø)

... and 238 files with indirect coverage changes

@robert-zaremba robert-zaremba enabled auto-merge June 7, 2024 16:57
@robert-zaremba robert-zaremba added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit 10f3261 Jun 7, 2024
21 of 22 checks passed
@robert-zaremba robert-zaremba deleted the robert/aucion-not-found branch June 7, 2024 17:04
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ee860df and 69f9877.

Files selected for processing (1)
  • x/auction/keeper/grpc_query.go (2 hunks)
Additional comments not posted (1)
x/auction/keeper/grpc_query.go (1)

7-8: Imports for google.golang.org/grpc/codes and google.golang.org/grpc/status added to support error handling.

Comment on lines +39 to +47
k := q.Keeper(&ctx)
rewards, id := k.getRewardsAuction(msg.Id)
if rewards == nil {
return nil, status.Error(codes.NotFound, "wrong ID")
}
r := &auction.QueryRewardsAuctionResponse{Id: id}
r.Rewards = rewards.Rewards
r.EndsAt = rewards.EndsAt

Copy link
Contributor

Choose a reason for hiding this comment

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

The error handling for a non-existent auction ID is correctly implemented. Consider improving the error message for clarity.

- return nil, status.Error(codes.NotFound, "wrong ID")
+ return nil, status.Error(codes.NotFound, "Auction ID not found")
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.

Suggested change
k := q.Keeper(&ctx)
rewards, id := k.getRewardsAuction(msg.Id)
if rewards == nil {
return nil, status.Error(codes.NotFound, "wrong ID")
}
r := &auction.QueryRewardsAuctionResponse{Id: id}
r.Rewards = rewards.Rewards
r.EndsAt = rewards.EndsAt
k := q.Keeper(&ctx)
rewards, id := k.getRewardsAuction(msg.Id)
if rewards == nil {
return nil, status.Error(codes.NotFound, "Auction ID not found")
}
r := &auction.QueryRewardsAuctionResponse{Id: id}
r.Rewards = rewards.Rewards
r.EndsAt = rewards.EndsAt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-e2e-test Skip the e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants