Skip to content

Conversation

@DaughterOfMars
Copy link
Contributor

Description

Adds the CommandArgumentError::InvalidArgumentArity variant.

Closes iotaledger/iota#8421

@DaughterOfMars DaughterOfMars requested a review from a team as a code owner September 2, 2025 11:54
Copy link

@Dkwcs Dkwcs left a comment

Choose a reason for hiding this comment

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

LGTM

@thibault-martinez thibault-martinez merged commit d7084ea into develop Sep 3, 2025
3 checks passed
@thibault-martinez thibault-martinez deleted the feat/invalid-arg-arity branch September 3, 2025 08:41
Dkwcs added a commit to iotaledger/iota that referenced this pull request Sep 5, 2025
…atting results (#8424)

# Description of change

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

### Behaviour Before and After
**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.


According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

## Links to any relevant issues

Fixes #8271 .

## How the change has been tested

iota-adapter-transactional-tests:

`cargo nextest run`
miker83z pushed a commit to iotaledger/iota that referenced this pull request Sep 8, 2025
…atting results (#8424)

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.

According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

Fixes #8271 .

iota-adapter-transactional-tests:

`cargo nextest run`
miker83z pushed a commit to iotaledger/iota that referenced this pull request Sep 8, 2025
…atting results (#8424)

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.

According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

Fixes #8271 .

iota-adapter-transactional-tests:

`cargo nextest run`
miker83z pushed a commit to iotaledger/iota that referenced this pull request Sep 8, 2025
…atting results (#8424)

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.

According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

Fixes #8271 .

iota-adapter-transactional-tests:

`cargo nextest run`
miker83z pushed a commit to iotaledger/iota that referenced this pull request Sep 8, 2025
…atting results (#8424)

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.

According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

Fixes #8271 .

iota-adapter-transactional-tests:

`cargo nextest run`
miker83z pushed a commit to iotaledger/iota that referenced this pull request Sep 10, 2025
…atting results (#8424)

The adapter now pre-normalizes PTB arguments that reference outputs from
earlier commands (“results”), including nested results, and fails early
on out-of-bounds indexes before typing executes. This is the first step
toward “xargs-style” PTB programming and potential future “splat”
ergonomics

Users get deterministic “index out of bounds” errors when they reference
non-existent inputs/results, rather than cryptic typing-phase or
execution-phase failures. (See Sui’s new tests where Input(1),
Result(1), or NestedResult(2,0) trip clean IndexOutOfBounds before
typing.

**Invalid `Input(i)` and `Result(k)` are caught early**

**Before (symptomatic)**
An invalid index could travel into typing/execution and surface as less
clear errors (e.g., invalid usage/object by value).

**After**
```
Error: Transaction Effects Status: Invalid command argument at 1.
Out of bounds access to input or result vector 100
Execution Error: ... CommandArgumentError { arg_idx: 1, kind: IndexOutOfBounds { idx: 100 } } ...
```

**Nested results `(NestedResult(k, j))` get validated**

If a prior command returns a tuple, you can reference an element with
NestedResult(k, j). The adapter now checks both k and j early.
Example from tests:

```
//# programmable
//> test::m::a();                // cmd 0, returns A
//> test::m::a2();               // cmd 1, returns (A, A)
//> test::m::take_b(Result(0), NestedResult(2, 0)) // '2' is out of range
```

This fails before typing with:
```
Invalid command argument at 1. Out of bounds access to input or result vector 2
... IndexOutOfBounds { idx: 2 } ...
```
because there are only prior results at indices 0 and 1.

According to
[changes](MystenLabs/sui@03806d3).

We also had to update
[iota-rust-sdk](iotaledger/iota-rust-sdk#177).

Fixes #8271 .

iota-adapter-transactional-tests:

`cargo nextest run`
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.

[iota-rust-sdk]: InvalidArgumentArity type is missing in CommandArgumentError

5 participants