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

proposal.String() panics with nested Anys #10965

Closed
4 tasks
amaury1093 opened this issue Jan 18, 2022 · 2 comments · Fixed by cosmos/gogoproto#24
Closed
4 tasks

proposal.String() panics with nested Anys #10965

amaury1093 opened this issue Jan 18, 2022 · 2 comments · Fixed by cosmos/gogoproto#24

Comments

@amaury1093
Copy link
Contributor

Summary of Bug

When calling .String() on a proto struct that has nested Anys, it panics. A quick debugging leads to the field any.cachedValue panicking.

panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

see stack

It seems to me that gogoproto panics when printing our Any's cachedValue.

ref: #10868 (comment)

Version

8f13e99

Steps to Reproduce

// TestNestedAnys tests that we can call .String() on a struct with nested Anys.
// Here, we're creating a proposal which has a Msg (1st any) with a legacy
// content (2nd any).
func TestNestedAnys(t *testing.T) {
testProposal := v1beta1.NewTextProposal("Proposal", "testing proposal")
msgContent, err := v1beta2.NewLegacyContent(testProposal, "cosmos1govacct")
require.NoError(t, err)
proposal, err := v1beta2.NewProposal([]sdk.Msg{msgContent}, 1, time.Now(), time.Now())
require.NoError(t, err)
require.Equal(t, "TODO Fix panic here", proposal.String())
}


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@fdymylja
Copy link
Contributor

fdymylja commented Jan 19, 2022

This needs to be fixed in regen proto fork I assume.

@julienrbrt
Copy link
Member

When we fix this, does that mean we are able to rely on String()?
And thus do not need this: https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/core/05-encoding.md#custom-stringer (see #12908)

@julienrbrt julienrbrt moved this from 💪 In Progress to 👀 Needs Review in Cosmos-SDK Nov 13, 2022
Repository owner moved this from 👀 Needs Review to 👏 Done in Cosmos-SDK Nov 14, 2022
@tac0turtle tac0turtle removed this from Cosmos-SDK Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants