Skip to content

Wrap errors returned from Store#404

Merged
tzdybal merged 9 commits intoevstack:mainfrom
mauriceLC92:mauriceLC92/wrap-errors-from-store
Jul 7, 2022
Merged

Wrap errors returned from Store#404
tzdybal merged 9 commits intoevstack:mainfrom
mauriceLC92:mauriceLC92/wrap-errors-from-store

Conversation

@mauriceLC92
Copy link
Copy Markdown
Contributor

Wraps errors returned from the Store

Copy link
Copy Markdown
Contributor

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

CI failing

@adlerjohn adlerjohn linked an issue May 14, 2022 that may be closed by this pull request
@mauriceLC92
Copy link
Copy Markdown
Contributor Author

Hmm I wonder if another flakey test? Ran the tests locally before opening PR and was fine. Also these failures look unrelated to the changes being added @tzdybal

@mauriceLC92 mauriceLC92 marked this pull request as ready for review May 15, 2022 17:34
Copy link
Copy Markdown
Contributor

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

The tests are failing consistently locally. I left comments.

Comment thread store/store.go Outdated
commit := new(types.Commit)
err = commit.UnmarshalBinary(commitData)
return commit, err
return commit, fmt.Errorf("error decoding binary data of Commit into object: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gotcha! In original case, if error was nil, nil was returned. Now, you're wrapping everytime, even if error is nil.

Suggested change
return commit, fmt.Errorf("error decoding binary data of Commit into object: %w", err)
if err != nil {
return nil, fmt.Errorf("error decoding binary data of Commit into object: %w", err)
}
return commit, nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated 👍

Comment thread store/store.go Outdated
err = json.Unmarshal(blob, &state)
atomic.StoreUint64(&s.height, uint64(state.LastBlockHeight))
return state, err
return state, fmt.Errorf("error unmarshalling state from JSON encoding: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated 👍

@mauriceLC92
Copy link
Copy Markdown
Contributor Author

The tests are failing consistently locally. I left comments.

Thank you! I realized I was running the test locally on main 😂 - Now failing for me too. Will address

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #404 (a030778) into main (644a85a) will decrease coverage by 0.06%.
The diff coverage is 25.92%.

@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
- Coverage   56.54%   56.47%   -0.07%     
==========================================
  Files          44       44              
  Lines        7518     7527       +9     
==========================================
  Hits         4251     4251              
- Misses       2659     2665       +6     
- Partials      608      611       +3     
Impacted Files Coverage Δ
store/store.go 64.05% <25.92%> (-4.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 644a85a...a030778. Read the comment docs.

@tzdybal tzdybal requested review from adlerjohn and tzdybal May 15, 2022 18:50
Copy link
Copy Markdown
Contributor

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Copy Markdown
Contributor

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

Comments seems a bit incoherent (for example error encoding Block into binary form and error marshalling state into JSON encoding) - please stick to single form.

Comment thread rpc/json/service_test.go Outdated
{"valid/no params", "/abci_info", http.StatusOK, -1, `"last_block_height":345`},
// to keep test simple, allow returning application error in following case
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), `"key not found"`},
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), "error loading hash by height 321: key not found"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that it might not be "stable" to include block number here.

Suggested change
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), "error loading hash by height 321: key not found"},
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), "error loading block hash for height"},

Comment thread store/store.go Outdated
var hash [32]byte
if err != nil {
return hash, err
return hash, fmt.Errorf("error loading hash by height %v: %w", height, err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return hash, fmt.Errorf("error loading hash by height %v: %w", height, err)
return hash, fmt.Errorf("error loading block hash for height %v: %w", height, err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @tzdybal sorry I am a little unsure as to what you mean by the singular form in this case

@adlerjohn adlerjohn changed the title Resolve - Wrap errors returned from Store Wrap errors returned from Store May 19, 2022
Copy link
Copy Markdown
Contributor

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

Now it looks way better :)

Comment thread store/store.go Outdated
blob, err := s.db.Get(getStateKey())
if err != nil {
return types.State{}, err
return types.State{}, fmt.Errorf("failed to retrieve key: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return types.State{}, fmt.Errorf("failed to retrieve key: %w", err)
return types.State{}, fmt.Errorf("failed to retrieve state: %w", err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated :)

Comment thread rpc/json/service_test.go Outdated
{"valid/no params", "/abci_info", http.StatusOK, -1, `"last_block_height":"345"`},
// to keep test simple, allow returning application error in following case
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), `"key not found"`},
{"valid/int param", "/block?height=321", http.StatusOK, int(json2.E_INTERNAL), "error loading block hash for height"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This won't pass.

@tzdybal tzdybal merged commit 8cd8832 into evstack:main Jul 7, 2022
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.

Wrap errors returned from Store

4 participants