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 chain not found error #3481

Merged
merged 10 commits into from
Jul 25, 2024

Conversation

vitaliy-io
Copy link
Collaborator

Fix api error message if chainID not found
Fix api error message if network prefix is incorrect

Nikita Nikolashyn and others added 2 commits July 25, 2024 13:36
fix: Chain lookup done even when network prefix in chain ID is wrong
@vitaliy-io vitaliy-io requested a review from jorgemmsilva July 25, 2024 12:40
@@ -65,7 +65,7 @@ func (c *Controller) getChainInfo(e echo.Context) error {
}

chainInfo, err := c.chainService.GetChainInfoByChainID(chainID, e.QueryParam(params.ParamBlockIndexOrTrieRoot))
if errors.Is(err, interfaces.ErrChainNotFound) {
if errors.As(err, &interfaces.ChainNotFoundError{}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jorgemmsilva please note style of usage of ChainNotFoundError.
errors.Is replaced with errors.As. There was another option - to add separate wrapper in addition to ErrChainNotFound, which will return it through Unwrap(). That would allow to keep errors.Is as it is now. But that would also split error into two separate parts, which we thought is not a nice thing to have.

@jorgemmsilva jorgemmsilva enabled auto-merge July 25, 2024 13:17
auto-merge was automatically disabled July 25, 2024 13:26

Head branch was pushed to by a user without write access

@@ -121,6 +127,10 @@ func (id ChainID) ShortString() string {

// String human-readable form (bech32)
func (id ChainID) String() string {
if id.Empty() {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably breaks the invariant:

ChainIDFromString(chainID.String()) == chainID

Maybe it's better to panic if the chainID is "empty"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or just return the bech32 as before. Why is the check needed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, thanks, actually I reverted it. It was accidentally pushed

@@ -121,6 +127,10 @@ func (id ChainID) ShortString() string {

// String human-readable form (bech32)
func (id ChainID) String() string {
if id.Empty() {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Or just return the bech32 as before. Why is the check needed?

@vitaliy-io vitaliy-io requested a review from jorgemmsilva July 25, 2024 13:55
@jorgemmsilva jorgemmsilva merged commit 54cb0e6 into iotaledger:develop Jul 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants