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

fix(store): avoid nil error on not exhausted payload stream #20644

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (store) [#20425](https://github.com/cosmos/cosmos-sdk/pull/20425) Fix nil pointer panic when query historical state where a new store don't exist.
* (store) [#20644](https://github.com/cosmos/cosmos-sdk/pull/20644) Avoid nil error on not exhausted payload stream.
Copy link
Contributor

Choose a reason for hiding this comment

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

The changelog entry succinctly captures the essence of the bug fix. However, consider rephrasing for clarity and grammatical correctness.

- * (store) [#20644](https://github.com/cosmos/cosmos-sdk/pull/20644) Avoid nil error on not exhausted payload stream.
+ * (store) [#20644](https://github.com/cosmos/cosmos-sdk/pull/20644) Fix nil error when the payload stream is not exhausted.
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* (store) [#20644](https://github.com/cosmos/cosmos-sdk/pull/20644) Avoid nil error on not exhausted payload stream.
* (store) [#20644](https://github.com/cosmos/cosmos-sdk/pull/20644) Fix nil error when the payload stream is not exhausted.


## v1.1.0 (March 20, 2024)

Expand Down
2 changes: 1 addition & 1 deletion store/snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (m *Manager) doRestoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.
}

if nextItem.GetExtensionPayload() != nil {
return errorsmod.Wrapf(err, "extension %s don't exhausted payload stream", metadata.Name)
return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion store/v2/snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func (m *Manager) doRestoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.
}

if nextItem.GetExtensionPayload() != nil {
return errorsmod.Wrapf(err, "extension %s don't exhausted payload stream", metadata.Name)
return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message grammar needs correction. Additionally, consider using errors.New for consistency with other error messages that do not format strings.

- return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
+ return errors.New("extension " + metadata.Name + " has not exhausted the payload stream")
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
return errors.New("extension " + metadata.Name + " has not exhausted the payload stream")

}
}

Expand Down
Loading