CosmWasm / CosmWasm/cw-storage-plus
Provide better errors when failing to load storage Items
- Dominant language
- Rust
- Stars
- 51
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
I have a set of contracts that use multiple `Item`. Now I get the following error message:
> failed to execute message; message index: 0: dispatch: submessages: alloc::string::String not found: execute wasm contract failed: invalid request
Unfortunately this does not help much to locate the issue. `alloc::string::String` is the `type_name::` in
```rust
/// must_deserialize parses json bytes from storage (Option), returning NotFound error if no data present
pub(crate) fn must_deserialize(value: &Option>) -> StdResult {
match value {
Some(vec) => from_slice(vec),
None => Err(StdError::not_found(type_name::())),
}
}
```
If I wasn't a core maintainer, the error message would be completety unreadable for me.
The error expresses that a key was not found and is emitted before trying to deserialize into any type. I think the key should become the main information in the error message. The type could be there too but maybe as an optional hint.
In order to address that, I think we should add a new error type to cosmwasm-std and deprecate `StdError::NotFound`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with must_deserialize and StdError::NotFound in the issue, then inspect how missing storage keys are represented and propagated through cosmwasm-std. Done means missing-key errors identify the storage key clearly, optionally retain type context, and the existing NotFound error is addressed as proposed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100