-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor: add close body after use and fix lint #22248
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request enhance the functionality of the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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.yml
Review profile: CHILL
📒 Files selected for processing (5)
- collections/quad.go (0 hunks)
- schema/indexer/start.go (1 hunks)
- server/v2/cometbft/abci.go (1 hunks)
- tests/integration/tx/aminojson/aminojson_test.go (0 hunks)
- tools/hubl/internal/registry.go (1 hunks)
💤 Files with no reviewable changes (2)
- collections/quad.go
- tests/integration/tx/aminojson/aminojson_test.go
✅ Files skipped from review due to trivial changes (1)
- server/v2/cometbft/abci.go
🧰 Additional context used
📓 Path-based instructions (2)
schema/indexer/start.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.tools/hubl/internal/registry.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🔇 Additional comments (1)
tools/hubl/internal/registry.go (1)
34-37
: Excellent addition of error handling for response body closure.The new code properly handles potential errors when closing the response body, which is a good practice for resource management. This change aligns well with Go's error handling conventions and helps prevent resource leaks.
schema/indexer/start.go
Outdated
@@ -120,7 +120,7 @@ func StartIndexing(opts IndexingOptions) (IndexingTarget, error) { | |||
|
|||
targetCfg.Config, err = unmarshalIndexerCustomConfig(targetCfg.Config, init.ConfigType) | |||
if err != nil { | |||
return IndexingTarget{}, fmt.Errorf("failed to unmarshal indexer config for target %q: %v", targetName, err) | |||
return IndexingTarget{}, fmt.Errorf("failed to unmarshal indexer config for target %q: %w", targetName, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Ensure consistent error wrapping by using %w
in all fmt.Errorf
calls
The following fmt.Errorf
instances in schema/indexer/start.go
do not use the %w
verb and should be updated to enhance error handling consistency:
return IndexingTarget{}, fmt.Errorf("indexer type %q not found", targetCfg.Type)
return IndexingTarget{}, fmt.Errorf("indexer filter options are not supported yet")
return nil, fmt.Errorf("can't convert %T to %T", cfg, IndexingConfig{})
Recommended Action:
Update these instances to utilize the %w
verb for error wrapping, ensuring that the original error is preserved and can be unwrapped later. For example:
return IndexingTarget{}, fmt.Errorf("indexer type %q not found: %w", targetCfg.Type, err)
This change aligns with Go's error handling best practices and improves the ability to trace error chains.
🔗 Analysis chain
Improved error wrapping using %w
verb
The change from %v
to %w
in the error formatting is a good improvement. This modification allows for better error handling and debugging capabilities.
Reasons for approval:
- Using
%w
verb wraps the original error, preserving the error chain. - This change aligns with Go 1.13+ error wrapping best practices.
- It follows the Uber Go Style Guide recommendation for error wrapping.
Suggestion for further improvement:
Consider updating other error handling instances in this file to use %w
where appropriate, for consistency. This would involve checking other fmt.Errorf
calls within the StartIndexing
function and potentially other functions in this file.
To ensure consistency across the file, let's check for other instances of error formatting:
This will help identify if there are other error formatting calls that might benefit from using %w
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other fmt.Errorf calls in the file
rg --type go 'fmt\.Errorf\(' schema/indexer/start.go
Length of output: 411
# Conflicts: # collections/quad.go
(cherry picked from commit 4274dcf) # Conflicts: # collections/quad.go # tools/hubl/internal/registry.go
#22260) Co-authored-by: Hoa Nguyen <[email protected]> Co-authored-by: Julien Robert <[email protected]>
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
getProtoRegistry
field in the Consensus struct.