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: remove cockroach db errors #20386

Merged
merged 3 commits into from
May 15, 2024
Merged

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented May 14, 2024

Description

this pr removes cockroachdberrors in all packages


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...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Bug Fixes

    • Standardized error handling by replacing github.com/cockroachdb/errors with standard errors package in multiple files for consistency.
    • Updated dependencies in gomod2nix.toml for compatibility and security.
  • Chores

    • Updated dependencies in gomod2nix.toml to ensure compatibility and security.
    • Replaced error handling from github.com/cockroachdb/errors with standard fmt.Errorf across multiple files for consistency.

Copy link
Contributor

coderabbitai bot commented May 14, 2024

Walkthrough

Walkthrough

The changes involve transitioning from the github.com/cockroachdb/errors package to the standard library errors or fmt package for error handling in various files. This update impacts error creation, formatting, and wrapping. Additionally, modifications to module versions and their hashes in simapp/gomod2nix.toml are included.

Changes

File Path Change Summary
baseapp/abci.go, baseapp/abci_utils.go, baseapp/baseapp.go Replaced github.com/cockroachdb/errors with the standard library errors.
client/cmd.go, client/query.go, client/v2/autocli/flag/binary.go, client/v2/autocli/flag/map.go Switched error handling from github.com/cockroachdb/errors to the standard library errors.
client/v2/autocli/flag/maps/generic.go Updated error handling in Set method to use fmt.Errorf instead of errors.Errorf.
client/v2/autocli/msg.go, client/v2/autocli/query.go Replaced errors.Errorf with fmt.Errorf for error formatting.
depinject/check_type.go, depinject/container.go, depinject/errors.go, depinject/group.go, depinject/one_per_module.go, depinject/provider_desc.go, depinject/struct_args.go Switched from github.com/cockroachdb/errors to fmt for error handling.
depinject/config.go Changed error handling to use github.com/pkg/errors and updated error creation and wrapping methods.
simapp/gomod2nix.toml Updated module versions and their corresponding hashes.
store/v2/root/store.go Replaced github.com/cockroachdb/errors with the standard library errors.
tools/hubl/internal/load.go Replaced cockroachdberrors with fmt.Errorf and errors.New for error handling.
x/circuit/ante/circuit.go, x/distribution/keeper/keeper.go, x/slashing/keeper/infractions.go Switched from github.com/cockroachdb/errors to the standard library errors.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@tac0turtle tac0turtle marked this pull request as ready for review May 14, 2024 15:56
@tac0turtle tac0turtle requested a review from a team as a code owner May 14, 2024 15:56
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: 22

Out of diff range and nitpick comments (4)
client/v2/autocli/flag/binary.go (1)

Line range hint 34-34: Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return errors.New("input string is neither a valid file path, hex, or base64 encoded")
+ return fmt.Errorf("input string is neither a valid file path, hex, or base64 encoded: %w", err)
depinject/config.go (3)

Line range hint 95-95: Use consistent import alias for pkgerrors.WithStack.

-				return errors.WithStack(err)
+				return pkgerrors.WithStack(err)

Line range hint 155-155: Use consistent import alias for pkgerrors.WithStack.

-		return errors.WithStack(err)
+		return pkgerrors.WithStack(err)

Line range hint 166-166: Use consistent import alias for pkgerrors.WithStack.

-				return errors.WithStack(err)
+				return pkgerrors.WithStack(err)
Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between fbc61d2 and 337548d.
Files ignored due to path filters (9)
  • client/v2/go.mod is excluded by !**/*.mod
  • depinject/go.mod is excluded by !**/*.mod
  • depinject/go.sum is excluded by !**/*.sum
  • go.mod is excluded by !**/*.mod
  • store/v2/go.mod is excluded by !**/*.mod
  • tools/hubl/go.mod is excluded by !**/*.mod
  • x/circuit/go.mod is excluded by !**/*.mod
  • x/distribution/go.mod is excluded by !**/*.mod
  • x/slashing/go.mod is excluded by !**/*.mod
Files selected for processing (24)
  • baseapp/abci.go (1 hunks)
  • baseapp/abci_utils.go (1 hunks)
  • baseapp/baseapp.go (1 hunks)
  • client/cmd.go (1 hunks)
  • client/query.go (1 hunks)
  • client/v2/autocli/flag/binary.go (1 hunks)
  • client/v2/autocli/flag/map.go (1 hunks)
  • client/v2/autocli/flag/maps/generic.go (2 hunks)
  • client/v2/autocli/msg.go (2 hunks)
  • client/v2/autocli/query.go (2 hunks)
  • depinject/check_type.go (2 hunks)
  • depinject/config.go (4 hunks)
  • depinject/container.go (9 hunks)
  • depinject/errors.go (2 hunks)
  • depinject/group.go (2 hunks)
  • depinject/one_per_module.go (5 hunks)
  • depinject/provider_desc.go (3 hunks)
  • depinject/struct_args.go (2 hunks)
  • simapp/gomod2nix.toml (7 hunks)
  • store/v2/root/store.go (1 hunks)
  • tools/hubl/internal/load.go (3 hunks)
  • x/circuit/ante/circuit.go (1 hunks)
  • x/distribution/keeper/keeper.go (1 hunks)
  • x/slashing/keeper/infractions.go (2 hunks)
Files skipped from review due to trivial changes (3)
  • client/query.go
  • depinject/struct_args.go
  • x/circuit/ante/circuit.go
Additional Context Used
GitHub Check Runs (5)
tests (03) failure (6)

depinject/config.go: [failure] 95-95:
undefined: errors.WithStack


depinject/config.go: [failure] 155-155:
undefined: errors.WithStack


depinject/config.go: [failure] 166-166:
undefined: errors.WithStack


depinject/config.go: [failure] 176-176:
undefined: errors.WithStack

tests (02) failure (6)

depinject/config.go: [failure] 95-95:
undefined: errors.WithStack


depinject/config.go: [failure] 155-155:
undefined: errors.WithStack


depinject/config.go: [failure] 166-166:
undefined: errors.WithStack


depinject/config.go: [failure] 176-176:
undefined: errors.WithStack

tests (01) failure (6)

depinject/config.go: [failure] 95-95:
undefined: errors.WithStack


depinject/config.go: [failure] 155-155:
undefined: errors.WithStack


depinject/config.go: [failure] 166-166:
undefined: errors.WithStack


depinject/config.go: [failure] 176-176:
undefined: errors.WithStack

tests (00) failure (6)

depinject/config.go: [failure] 95-95:
undefined: errors.WithStack


depinject/config.go: [failure] 155-155:
undefined: errors.WithStack


depinject/config.go: [failure] 166-166:
undefined: errors.WithStack


depinject/config.go: [failure] 176-176:
undefined: errors.WithStack

dependency-review failure (5)

depinject/config.go: [failure] 95-95:
undefined: errors.WithStack


depinject/config.go: [failure] 155-155:
undefined: errors.WithStack


depinject/config.go: [failure] 166-166:
undefined: errors.WithStack


depinject/config.go: [failure] 176-176:
undefined: errors.WithStack

Path-based Instructions (20)
client/v2/autocli/flag/maps/generic.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/v2/autocli/flag/binary.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/check_type.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/errors.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/group.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/one_per_module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/provider_desc.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

tools/hubl/internal/load.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/v2/autocli/query.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/slashing/keeper/infractions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/v2/autocli/msg.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/v2/autocli/flag/map.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/distribution/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

store/v2/root/store.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/cmd.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

depinject/container.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

baseapp/abci_utils.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

baseapp/baseapp.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

baseapp/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (61)
depinject/config.go (2)

37-37: Correct usage of errors.New for error handling.


84-84: Correct usage of errors.New for error handling.

client/v2/autocli/query.go (2)

65-65: Correct usage of fmt.Errorf for error handling.


65-65: Correct usage of fmt.Errorf for error handling.

x/slashing/keeper/infractions.go (1)

77-77: Correct usage of fmt.Errorf for error handling.

client/v2/autocli/msg.go (2)

71-71: Correct usage of fmt.Errorf for error handling.


71-71: Correct usage of fmt.Errorf for error handling.

client/v2/autocli/flag/map.go (1)

5-5: Correct usage of errors.New for error handling.

x/distribution/keeper/keeper.go (1)

5-5: Import standard library errors package.

store/v2/root/store.go (1)

5-5: Import standard library errors package.

client/cmd.go (1)

6-6: Import standard library errors package.

depinject/container.go (6)

64-64: LGTM! The use of fmt.Errorf for cyclic dependency error handling is appropriate.


88-88: LGTM! The use of fmt.Errorf for handling errors when calling a provider is appropriate.


297-298: LGTM! The use of fmt.Errorf for handling errors related to declaring dependencies is appropriate.


318-320: LGTM! The use of fmt.Errorf for handling errors related to duplicate provision of types is appropriate.


379-380: LGTM! The use of fmt.Errorf for handling errors when resolving ModuleKey is appropriate.


388-389: LGTM! The use of fmt.Errorf for handling errors when resolving OwnModuleKey is appropriate.

baseapp/abci_utils.go (1)

6-6: LGTM! The import of the errors package from the standard library is appropriate.

simapp/gomod2nix.toml (13)

5-6: Ensure the version and hash for buf.build/gen/go/cometbft/cometbft/protocolbuffers/go are correct.

Verification successful

The version and hash for buf.build/gen/go/cometbft/cometbft/protocolbuffers/go in simapp/gomod2nix.toml are correct.

  • Version: v1.34.0-20240312114316-c0d3497e35d6.1
  • Hash: sha256-Uoo+Gfx/mnzKRoBvmTJC7oUKMrxOT20ibdY6ArGKHLQ=
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for buf.build/gen/go/cometbft/cometbft/protocolbuffers/go
expected_version="v1.34.0-20240312114316-c0d3497e35d6.1"
expected_hash="sha256-Uoo+Gfx/mnzKRoBvmTJC7oUKMrxOT20ibdY6ArGKHLQ="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 278


8-9: Ensure the version and hash for buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go are correct.

Verification successful

The version and hash for buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go in simapp/gomod2nix.toml are correct.

  • Version: v1.34.0-20240130113600-88ef6483f90f.1
  • Hash: sha256-EpsIiMf8GKK56FgjSS3tCZtVCz4apPcJiaqsbhtF3kM=
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go
expected_version="v1.34.0-20240130113600-88ef6483f90f.1"
expected_hash="sha256-EpsIiMf8GKK56FgjSS3tCZtVCz4apPcJiaqsbhtF3kM="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 278


276-277: Ensure the version and hash for github.com/hashicorp/go-hclog are correct.


390-391: Ensure the version and hash for github.com/pelletier/go-toml/v2 are correct.


402-403: Ensure the version and hash for github.com/prometheus/client_golang are correct.

Verification successful

Version and hash for github.com/prometheus/client_golang are correct

The version v1.19.1 and hash sha256-MSLsMDi89uQc7Pa2fhqeamyfPJpenGj3r+eB/UotK7w= for github.com/prometheus/client_golang are correctly specified in simapp/gomod2nix.toml.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for github.com/prometheus/client_golang
expected_version="v1.19.1"
expected_hash="sha256-MSLsMDi89uQc7Pa2fhqeamyfPJpenGj3r+eB/UotK7w="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 218


514-515: Ensure the version and hash for golang.org/x/crypto are correct.


517-518: Ensure the version and hash for golang.org/x/exp are correct.

Verification successful

The version and hash for golang.org/x/exp in simapp/gomod2nix.toml are correct.

  • Version: v0.0.0-20240506185415-9bf2ced13842
  • Hash: sha256-5JZE4OhePWHtObIT4RJOS+2zv265Io1yJkFeE8wHXY4=
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/exp
expected_version="v0.0.0-20240506185415-9bf2ced13842"
expected_hash="sha256-5JZE4OhePWHtObIT4RJOS+2zv265Io1yJkFeE8wHXY4="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 272



Script:

#!/bin/bash
# Extract the section for golang.org/x/exp and verify the version and hash
grep -A 2 'golang.org/x/exp' simapp/gomod2nix.toml

Length of output: 193


523-524: Ensure the version and hash for golang.org/x/net are correct.


532-533: Ensure the version and hash for golang.org/x/sys are correct.


535-536: Ensure the version and hash for golang.org/x/term are correct.

Verification successful

The version and hash for golang.org/x/term in simapp/gomod2nix.toml are correct.

  • Version: v0.20.0
  • Hash: sha256-kU+OVJbYktTIn4ZTAdomsOjL069Vj45sdroEMRKaRDI=
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/term
expected_version="v0.20.0"
expected_hash="sha256-kU+OVJbYktTIn4ZTAdomsOjL069Vj45sdroEMRKaRDI="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 218


538-539: Ensure the version and hash for golang.org/x/text are correct.

Verification successful

The version and hash for golang.org/x/text are correctly set to v0.15.0 and sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk= respectively in the simapp/gomod2nix.toml file.

  • [mod."golang.org/x/text"]
    • version = "v0.15.0"
    • hash = "sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk="
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/text
expected_version="v0.15.0"
expected_hash="sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 218



Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/text are correctly associated
grep -A 2 'golang.org/x/text' simapp/gomod2nix.toml | grep -q 'version = "v0.15.0"' && grep -A 2 'golang.org/x/text' simapp/gomod2nix.toml | grep -q 'hash = "sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk="'

Length of output: 208



Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/text are correctly associated
grep -A 2 'golang.org/x/text' simapp/gomod2nix.toml | grep -q 'version = "v0.15.0"' && grep -A 2 'golang.org/x/text' simapp/gomod2nix.toml | grep -q 'hash = "sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk="'

Length of output: 208



Script:

#!/bin/bash
# Verify the version and hash for golang.org/x/text are correctly associated
grep -A 2 'golang.org/x/text' simapp/gomod2nix.toml

Length of output: 168


544-545: Ensure the version and hash for golang.org/x/tools are correct.


556-557: Ensure the version and hash for google.golang.org/genproto/googleapis/rpc are correct.

Verification successful

The version and hash for google.golang.org/genproto/googleapis/rpc in simapp/gomod2nix.toml are correct.

  • Version: v0.0.0-20240509183442-62759503f434
  • Hash: sha256-w2SGX12NeDO33wjxEpHi+OMcpp9SioPtdBuZKUIun+U=
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for google.golang.org/genproto/googleapis/rpc
expected_version="v0.0.0-20240509183442-62759503f434"
expected_hash="sha256-w2SGX12NeDO33wjxEpHi+OMcpp9SioPtdBuZKUIun+U="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 272

baseapp/baseapp.go (10)

5-5: Import change looks good.


Line range hint 88-92: Error handling changes in AppVersion method look good.


Line range hint 276-278: Error handling changes in LoadLatestVersion method look good.


Line range hint 297-299: Error handling changes in LoadVersion method look good.


Line range hint 344-346: Error handling changes in Init method look good.


Line range hint 526-528: Error handling changes in StoreConsensusParams method look good.


Line range hint 764-766: Error handling changes in runTx method look good.


Line range hint 1044-1046: Error handling changes in runMsgs method look good.


Line range hint 1087-1089: Error handling changes in createEvents method look good.


Line range hint 1241-1243: Error handling changes in Close method look good.

baseapp/abci.go (20)

Line range hint 14-14: Import standard library errors instead of github.com/cockroachdb/errors.


Line range hint 32-32: Use fmt.Errorf for error formatting.


Line range hint 61-61: Use fmt.Errorf for error formatting.


Line range hint 69-69: Use fmt.Errorf for error formatting.


Line range hint 83-83: Use fmt.Errorf for error formatting.


Line range hint 101-101: Use fmt.Errorf for error formatting.


Line range hint 118-118: Use fmt.Errorf for error formatting.


Line range hint 132-132: Use fmt.Errorf for error formatting.


Line range hint 144-144: Use fmt.Errorf for error formatting.


Line range hint 158-158: Use fmt.Errorf for error formatting.


Line range hint 176-176: Use fmt.Errorf for error wrapping.


Line range hint 180-180: Use fmt.Errorf for error wrapping.


Line range hint 319-319: Use errors.Is for error comparison.


Line range hint 322-322: Use errors.Is for error comparison.


Line range hint 353-353: Use errors.Is for error comparison.


Line range hint 387-387: Use fmt.Errorf for error formatting.


Line range hint 409-409: Use errors.New for error creation.


Line range hint 417-417: Use errors.New for error creation.


Line range hint 466-466: Use errors.New for error creation.


Line range hint 474-474: Use errors.New for error creation.

Comment on lines 48 to 52
return pkgerrors.WithStack(err)
}
_, err = ctr.addNode(&rc, key)
if err != nil {
return errors.WithStack(err)
return pkgerrors.WithStack(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use consistent import alias for pkgerrors.WithStack.

-			return pkgerrors.WithStack(err)
+			return errors.WithStack(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.

Suggested change
return pkgerrors.WithStack(err)
}
_, err = ctr.addNode(&rc, key)
if err != nil {
return errors.WithStack(err)
return pkgerrors.WithStack(err)
return errors.WithStack(err)
}
_, err = ctr.addNode(&rc, key)
if err != nil {
return pkgerrors.WithStack(err)

@@ -31,7 +30,7 @@ func (gm *genericMapValue[K, V]) Set(val string) error {
for _, pair := range ss {
kv := strings.SplitN(pair, "=", 2)
if len(kv) != 2 {
return errors.Errorf("%s must be formatted as key=value", pair)
return fmt.Errorf("%s must be formatted as key=value", pair)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return fmt.Errorf("%s must be formatted as key=value", pair)
+ return fmt.Errorf("%s must be formatted as key=value: %w", pair, 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.

Suggested change
return fmt.Errorf("%s must be formatted as key=value", pair)
return fmt.Errorf("%s must be formatted as key=value: %w", pair, err)

@@ -21,12 +21,12 @@ func isExportedType(typ reflect.Type) error {
pkgPath := typ.PkgPath()
if name != "" && pkgPath != "" {
if unicode.IsLower([]rune(name)[0]) {
return errors.Errorf("type must be exported: %s", typ)
return fmt.Errorf("type must be exported: %s", typ)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return fmt.Errorf("type must be exported: %s", typ)
+ return fmt.Errorf("type must be exported: %w", typ)

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
return fmt.Errorf("type must be exported: %s", typ)
return fmt.Errorf("type must be exported: %w", typ)

}

pkgParts := strings.Split(pkgPath, "/")
if slices.Contains(pkgParts, "internal") {
return errors.Errorf("type must not come from an internal package: %s", typ)
return fmt.Errorf("type must not come from an internal package: %s", typ)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return fmt.Errorf("type must not come from an internal package: %s", typ)
+ return fmt.Errorf("type must not come from an internal package: %w", typ)

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
return fmt.Errorf("type must not come from an internal package: %s", typ)
return fmt.Errorf("type must not come from an internal package: %w", typ)

Comment on lines +64 to 66
return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %s",
typ, duplicateLoc, existingLoc)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %s",
- typ, duplicateLoc, existingLoc)
+ return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %w",
+ typ, duplicateLoc, existingLoc)

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
return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %s",
typ, duplicateLoc, existingLoc)
}
return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %w",
typ, duplicateLoc, existingLoc)

@@ -108,7 +108,7 @@
t := typ.Out(i)
if t == errType {
if i != numOut-1 {
return providerDescriptor{}, errors.Errorf("output error parameter is not last parameter in function %s", loc)
return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %s", loc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %s", loc)
+ return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %w", loc)

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
return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %s", loc)
return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %w", loc)

@@ -183,7 +182,7 @@ func (c *ChainInfo) OpenClient() (*grpc.ClientConn, error) {
return c.client, nil
}

return nil, cockroachdberrors.Wrapf(res, "error loading gRPC client")
return nil, fmt.Errorf("error loading gRPC client: %w", res)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return nil, fmt.Errorf("error loading gRPC client: %w", res)
+ return nil, fmt.Errorf("error loading gRPC client: %v", res)

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
return nil, fmt.Errorf("error loading gRPC client: %w", res)
return nil, fmt.Errorf("error loading gRPC client: %v", res)

@@ -195,7 +194,7 @@
}

if resp == nil || resp.Bech32Prefix == "" {
return "", cockroachdberrors.New("bech32 account address prefix is not set")
return "", errors.New("bech32 account address prefix is not set")
Copy link
Contributor

Choose a reason for hiding this comment

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

Use %w for error wrapping.

To wrap errors correctly and preserve the original error context, use %w instead of %v in fmt.Errorf.

- return "", errors.New("bech32 account address prefix is not set")
+ return "", fmt.Errorf("bech32 account address prefix is not set: %w", 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.

Suggested change
return "", errors.New("bech32 account address prefix is not set")
return "", fmt.Errorf("bech32 account address prefix is not set: %w", err)

Comment on lines +135 to +136
version = "v1.1.4"
hash = "sha256-bBU5w5rEMvpCWSzFBIVvnMHnsy2+a+e1DPDkb4hNOwU="
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The version and hash for github.com/cosmos/iavl in simapp/gomod2nix.toml are incorrect.

  • Expected version: v1.1.4
  • Found version: v1.2.0

Please update the version to v1.2.0 and ensure the hash is correctly fetched and updated.

Analysis chain

Ensure the version and hash for github.com/cosmos/iavl are correct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for github.com/cosmos/iavl
expected_version="v1.1.4"
expected_hash="sha256-bBU5w5rEMvpCWSzFBIVvnMHnsy2+a+e1DPDkb4hNOwU="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 216



Script:

#!/bin/bash
# Fetch the latest version and hash for github.com/cosmos/iavl from the official repository
repo_url="https://github.com/cosmos/iavl"
latest_version=$(git ls-remote --tags $repo_url | grep -o 'refs/tags/v[0-9]*\.[0-9]*\.[0-9]*' | sort -V | tail -n1 | sed 's/refs\/tags\///')
latest_hash=$(nix-prefetch-git $repo_url --rev $latest_version | jq -r .sha256)

# Compare with the expected values
expected_version="v1.1.4"
expected_hash="sha256-bBU5w5rEMvpCWSzFBIVvnMHnsy2+a+e1DPDkb4hNOwU="

if [[ "$latest_version" == "$expected_version" && "$latest_hash" == "$expected_hash" ]]; then
  echo "The version and hash for github.com/cosmos/iavl are correct."
else
  echo "The version and hash for github.com/cosmos/iavl are incorrect."
  echo "Expected version: $expected_version, Found version: $latest_version"
  echo "Expected hash: $expected_hash, Found hash: $latest_hash"
fi

Length of output: 932

Comment on lines +562 to +563
version = "v1.34.1"
hash = "sha256-qnHqY6KLZiZDbTVTN6uzF4jedxROYlPCYHoiv6XI0sc="
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The version and hash for google.golang.org/protobuf are incorrect

The verification script has confirmed that the version and hash for google.golang.org/protobuf in the simapp/gomod2nix.toml file are incorrect.

  • Expected version: v1.34.1
  • Expected hash: (hash retrieval failed due to missing nix-prefetch-url command)
  • Found version: Multiple versions listed, including v1.34.0-20240312114316-c0d3497e35d6.1
  • Found hash: Multiple hashes listed, including sha256-qnHqY6KLZiZDbTVTN6uzF4jedxROYlPCYHoiv6XI0sc=

Please update the file to reflect the correct version and hash for google.golang.org/protobuf.

Analysis chain

Ensure the version and hash for google.golang.org/protobuf are correct.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the version and hash for google.golang.org/protobuf
expected_version="v1.34.1"
expected_hash="sha256-qnHqY6KLZiZDbTVTN6uzF4jedxROYlPCYHoiv6XI0sc="
grep -q "$expected_version" simapp/gomod2nix.toml && grep -q "$expected_hash" simapp/gomod2nix.toml

Length of output: 218



Script:

#!/bin/bash
# Fetch the latest version and hash for google.golang.org/protobuf from a reliable source
# and compare them with the values in simapp/gomod2nix.toml

# Fetch the latest version and hash from the Go module proxy
module="google.golang.org/protobuf"
latest_version=$(curl -s "https://proxy.golang.org/${module}/@latest" | jq -r .Version)
latest_hash=$(nix-prefetch-url --unpack "https://proxy.golang.org/${module}/@v/${latest_version}.zip")

# Extract the version and hash from the file
file_version=$(grep -oP 'version = "\K[^"]+' simapp/gomod2nix.toml)
file_hash=$(grep -oP 'hash = "sha256-\K[^"]+' simapp/gomod2nix.toml)

# Compare the values
if [[ "$latest_version" == "$file_version" && "$latest_hash" == "$file_hash" ]]; then
  echo "The version and hash for google.golang.org/protobuf are correct."
else
  echo "The version and hash for google.golang.org/protobuf are incorrect."
  echo "Expected version: $latest_version"
  echo "Expected hash: sha256-$latest_hash"
  echo "Found version: $file_version"
  echo "Found hash: sha256-$file_hash"
fi

Length of output: 37872

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: 9

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 337548d and 010dd44.
Files ignored due to path filters (2)
  • depinject/go.mod is excluded by !**/*.mod
  • depinject/go.sum is excluded by !**/*.sum
Files selected for processing (1)
  • depinject/config.go (9 hunks)
Additional Context Used
Path-based Instructions (1)
depinject/config.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Comment on lines +4 to +5
"errors"
"fmt"
Copy link
Contributor

Choose a reason for hiding this comment

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

Use consistent import alias for pkgerrors.WithStack.

-	"errors"
+	pkgerrors "github.com/pkg/errors"

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
"errors"
"fmt"
pkgerrors "github.com/pkg/errors"
"fmt"

@@ -33,7 +34,7 @@
func ProvideInModule(moduleName string, providers ...interface{}) Config {
return containerConfig(func(ctr *container) error {
if moduleName == "" {
return errors.Errorf("expected non-empty module name")
return errors.New("expected non-empty module name")
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider providing more context in the error message.

-			return errors.New("expected non-empty module name")
+			return errors.New("ProvideInModule: expected non-empty module name")

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
return errors.New("expected non-empty module name")
return errors.New("ProvideInModule: expected non-empty module name")

@@ -44,11 +45,11 @@
for _, c := range providers {
rc, err := extractProviderDescriptor(c)
if err != nil {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

-			return fmt.Errorf("%w\n%s", err, getStackTrace())
+			return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

}
_, err = ctr.addNode(&rc, key)
if err != nil {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

-			return fmt.Errorf("%w\n%s", err, getStackTrace())
+			return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

@@ -80,7 +81,7 @@
func InvokeInModule(moduleName string, invokers ...interface{}) Config {
return containerConfig(func(ctr *container) error {
if moduleName == "" {
return errors.Errorf("expected non-empty module name")
return errors.New("expected non-empty module name")
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider providing more context in the error message.

-			return errors.New("expected non-empty module name")
+			return errors.New("InvokeInModule: expected non-empty module name")

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
return errors.New("expected non-empty module name")
return errors.New("InvokeInModule: expected non-empty module name")

@@ -91,7 +92,7 @@
for _, c := range invokers {
rc, err := extractInvokerDescriptor(c)
if err != nil {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

-			return fmt.Errorf("%w\n%s", err, getStackTrace())
+			return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

@@ -151,7 +152,7 @@
for _, v := range values {
err := ctr.supply(reflect.ValueOf(v), loc)
if err != nil {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

-				return fmt.Errorf("%w\n%s", err, getStackTrace())
+				return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

@@ -162,7 +163,7 @@
// fail immediately.
func Error(err error) Config {
return containerConfig(func(*container) error {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

		return fmt.Errorf("%w\n%s", err, getStackTrace())
+		return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

@@ -172,7 +173,7 @@
for _, opt := range opts {
err := opt.apply(ctr)
if err != nil {
return errors.WithStack(err)
return fmt.Errorf("%w\n%s", err, getStackTrace())
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid including stack trace in error messages; use pkgerrors.WithStack instead.

				return fmt.Errorf("%w\n%s", err, getStackTrace())
+				return pkgerrors.WithStack(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.

Suggested change
return fmt.Errorf("%w\n%s", err, getStackTrace())
return pkgerrors.WithStack(err)

depinject/config.go Dismissed Show dismissed Hide dismissed
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

I remember it was done for getting a stacktrace or smth. But lgtm!

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: 0

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 010dd44 and 9f564f7.
Files selected for processing (2)
  • client/v2/autocli/msg.go (2 hunks)
  • runtime/v2/store.go (1 hunks)
Files not reviewed due to errors (1)
  • runtime/v2/store.go (no review received)
Files skipped from review as they are similar to previous changes (1)
  • client/v2/autocli/msg.go
Additional Context Used
Path-based Instructions (1)
runtime/v2/store.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

@tac0turtle
Copy link
Member Author

I remember it was done for getting a stacktrace or smth. But lgtm!

we should make sure we consider where stack traces are returned. Items where its user facing, not really a concern. Areas where it's useful for debugging and isolation of errors to reproduce the issue more so. Im not sure if there is a performance overhead with it but dont think its 0

@tac0turtle tac0turtle added this pull request to the merge queue May 15, 2024
Merged via the queue into main with commit 080229f May 15, 2024
73 checks passed
@tac0turtle tac0turtle deleted the marko/remove_cockroachdb_errors branch May 15, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants