Skip to content

Commit

Permalink
refactor: remove redacted message (backport cosmos#11960) (cosmos#12002)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored and Eengineer1 committed Aug 26, 2022
1 parent cd9f2af commit 39eab3f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* (x/feegrant) [\#11813](https://github.com/cosmos/cosmos-sdk/pull/11813) Fix pagination total count in `AllowancesByGranter` query.
* (errors) [\#12002](https://github.com/cosmos/cosmos-sdk/pull/12002) Removed 'redacted' error message from defaultErrEncoder.

### Bug Fixes

Expand Down
21 changes: 2 additions & 19 deletions types/errors/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,15 @@ func debugErrEncoder(err error) string {
return fmt.Sprintf("%+v", err)
}

// The defaultErrEncoder applies Redact on the error before encoding it with its internal error message.
func defaultErrEncoder(err error) string {
return Redact(err).Error()
return err.Error()
}

type coder interface {
ABCICode() uint32
}

// abciCode test if given error contains an ABCI code and returns the value of
// abciCode tests if given error contains an ABCI code and returns the value of
// it if available. This function is testing for the causer interface as well
// and unwraps the error.
func abciCode(err error) uint32 {
Expand Down Expand Up @@ -190,19 +189,3 @@ func errIsNil(err error) bool {
}
return false
}

var errPanicWithMsg = Wrapf(ErrPanic, "error message redacted to hide potential sensitive info. Use the '--trace' flag if you are running a node to see the full stack trace error")

// Redact replaces an error that is not initialized as an ABCI Error with a
// generic internal error instance. If the error is an ABCI Error, that error is
// simply returned.
func Redact(err error) error {
if ErrPanic.Is(err) {
return errPanicWithMsg
}
if abciCode(err) == internalABCICode {
return errInternal
}

return err
}

0 comments on commit 39eab3f

Please sign in to comment.