* fix: return 404 on non-existing tx (#10992)
(cherry picked from commit 158128953c
)
# Conflicts:
# CHANGELOG.md
* fix cl
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
This commit is contained in:
parent
ced57ea5de
commit
7ecf4d4ed4
|
@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (grpc) [\#10985](https://github.com/cosmos/cosmos-sdk/pull/10992) The `/cosmos/tx/v1beta1/txs/{hash}` endpoint returns a 404 when a tx does not exist.
|
||||
|
||||
## [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) - 2022-01-18
|
||||
|
||||
### State Machine Breaking
|
||||
|
|
|
@ -131,10 +131,18 @@ func (s txServer) GetTx(ctx context.Context, req *txtypes.GetTxRequest) (*txtype
|
|||
return nil, status.Error(codes.InvalidArgument, "request cannot be nil")
|
||||
}
|
||||
|
||||
if len(req.Hash) == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "tx hash cannot be empty")
|
||||
}
|
||||
|
||||
// TODO We should also check the proof flag in gRPC header.
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/7036.
|
||||
result, err := QueryTx(s.clientCtx, req.Hash)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return nil, status.Errorf(codes.NotFound, "tx not found: %s", req.Hash)
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -331,8 +331,8 @@ func (s IntegrationTestSuite) TestGetTx_GRPC() {
|
|||
expErrMsg string
|
||||
}{
|
||||
{"nil request", nil, true, "request cannot be nil"},
|
||||
{"empty request", &tx.GetTxRequest{}, true, "transaction hash cannot be empty"},
|
||||
{"request with dummy hash", &tx.GetTxRequest{Hash: "deadbeef"}, true, "tx (DEADBEEF) not found"},
|
||||
{"empty request", &tx.GetTxRequest{}, true, "tx hash cannot be empty"},
|
||||
{"request with dummy hash", &tx.GetTxRequest{Hash: "deadbeef"}, true, "code = NotFound desc = tx not found: deadbeef"},
|
||||
{"good request", &tx.GetTxRequest{Hash: s.txRes.TxHash}, false, ""},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
@ -361,12 +361,12 @@ func (s IntegrationTestSuite) TestGetTx_GRPCGateway() {
|
|||
{
|
||||
"empty params",
|
||||
fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/", val.APIAddress),
|
||||
true, "transaction hash cannot be empty",
|
||||
true, "tx hash cannot be empty",
|
||||
},
|
||||
{
|
||||
"dummy hash",
|
||||
fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", val.APIAddress, "deadbeef"),
|
||||
true, "tx (DEADBEEF) not found",
|
||||
true, "code = NotFound desc = tx not found: deadbeef",
|
||||
},
|
||||
{
|
||||
"good hash",
|
||||
|
|
Loading…
Reference in New Issue