cosmos-rust icon indicating copy to clipboard operation
cosmos-rust copied to clipboard

Error with user entered invalid UTF8 for protobuf structs.

Open penso opened this issue 2 years ago • 0 comments

If you look at https://testnet-explorer.publicawesome.dev/stargaze/tx/F31D90E03B1F9020A5B99D726E82B65BB24CE938CC99DDD0B40DA28BA9B178A9 the description field is malformed UTF8 and trying to decode it gets me a failed to decode Protobuf message: SudoContractProposal.description: invalid string value: data is not UTF-8 encoded

The protobuf type is defined at:

https://github.com/cosmos/cosmos-rust/blob/df40384c9d2f3167948e5773750d7d602ce04f53/cosmos-sdk-proto/src/prost/wasmd/cosmwasm.wasm.v1.rs#L511

with description as a String.

Since those String are user-defined, this error could easily occurs. This prevents me from parsing the whole message, and therefor see other attributes. I'm not sure what's the best solution here.

One way could be having Vec<u8> instead of String for user-defined attributes instead, and then suggest to convert that to UTF8 if needs to be? Having two structs, one with String and one with Vec<u8> feels overkill.

penso avatar Nov 01 '23 12:11 penso