Panic when constructing a dynamic transaction with invalid arguments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 489
- Forks
- 293
- Avg merge
- 18h 35m
- Merged PRs (30d)
- 3
Description
I encountered a panic! in the subxt library when attempting to construct a dynamic transaction call_data with invalid arguments.
The issue occurs in this specific line of codehttps://github.com/paritytech/subxt/blob/master/core/src/tx/payload.rs#L186
Error output:
The fields are valid types from the metadata, qed;: Error { context: Context { path: [Location { inner: Index(0) }] }, kind: WrongShape { actual: Number, expected_id: "13" } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Steps to Reproduce
let arg = scale_value::stringify::from_str_custom()
.add_custom_parser(custom_parsers::parse_hex)
.add_custom_parser(custom_parsers::parse_ss58)
.parse("123")
.0?;
subxt::dynamic::tx("System", "remark", parsed_args);
let call_data = tx.encode_call_data(&client.metadata());
I should ensure proper validation of the requested arguments before constructing the transaction. However, if the provided arguments are invalid, it would be ideal for the encode_call_data function to throw a meaningful error instead of causing a panic.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at core/src/tx/payload.rs:186 and reproduce the panic with the dynamic System::remark transaction and invalid parsed arguments shown in the issue. Trace encode_call_data and inspect the existing error handling. Done means invalid arguments return a meaningful error instead of panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100