diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 828414f1e2..365d7b31f2 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -374,7 +374,11 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) (res sdk.ErrUnknownRequest("No route for custom query specified").QueryResult() } querier := app.queryRouter.Route(path[1]) - ctx := app.checkState.ctx + if querier == nil { + sdk.ErrUnknownRequest(fmt.Sprintf("no custom querier found for route %s", path[1])).QueryResult() + } + + ctx := sdk.NewContext(app.cms.CacheMultiStore(), app.checkState.ctx.BlockHeader(), true, app.Logger) // Passes the rest of the path as an argument to the querier. // For example, in the path "custom/gov/proposal/test", the gov querier gets []string{"proposal", "test"} as the path resBytes, err := querier(ctx, path[2:], req)