Skip to content

contract invoke silently drops or accepts missing values in a tuple struct array argument #2748

Description

@leighmcculloch

What version are you using?

stellar-cli 28.0.0.

What did you do?

I deployed a small contract with a function that takes a tuple struct argument, and passed that argument as a JSON array: once with the right number of values, and then with too many and too few.

#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Env};

#[contracttype]
pub struct Point(u32, u32);

#[contract]
pub struct Contract;

#[contractimpl]
impl Contract {
    pub fn tuple_arg(_env: Env, point: Point) -> Point {
        point
    }
}
stellar contract build
stellar keys generate demo --network testnet --fund
stellar contract deploy \
  --wasm target/wasm32v1-none/release/repro_contract.wasm \
  --source demo --network testnet --alias repro_demo

Correct call:

stellar contract invoke --id repro_demo --source demo --network testnet --send no -- \
  tuple_arg --point '[1,2]'

Mis-sized calls — same command, but with three values, one value, or none:

stellar contract invoke --id repro_demo --source demo --network testnet --send no -- \
  tuple_arg --point '[1,2,3]'

stellar contract invoke --id repro_demo --source demo --network testnet --send no -- \
  tuple_arg --point '[1]'

stellar contract invoke --id repro_demo --source demo --network testnet --send no -- \
  tuple_arg --point '[]'

What did you expect to see?

A normal CLI error telling me the --point argument has the wrong number of values, the same way the CLI rejects --point '{"0":1}' with a missing key error.

What did you see instead?

The CLI accepts all three mis-sized arguments. With [1,2,3] the extra value is silently dropped and the contract is called with Point(1, 2), so the invocation succeeds with an argument I didn't pass. With [1] and [] the CLI builds a one-element and an empty vector and sends them on, so the mistake only surfaces later, from simulation or the contract, rather than as an argument error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status
      Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions