Skip to content

Bug: CLI exits 0 on command failure #864

@nopbody

Description

@nopbody

ref #859

Lost/trapped Funds
No

NOT SURE IF ITS INTENTIONAL

Describe the bug
The asb-controller CLI always exits with code 0 even when commands fail, breaking shell scripts and automation that rely on exit codes.

Location: in main.rs line ~ 14 to 21

match cli.cmd {
    None => repl::run(client, dispatch).await?,
    Some(cmd) => {
        if let Err(e) = dispatch(cmd.clone(), client.clone()).await {
            eprintln!("Command failed with error: {e:?}");
            // Error printed but not propagated - exits 0
        }
    }
}
Ok(())  // Always returns Ok(())

Reproduction:

$ ./target/release/asb-controller --url http://127.0.0.1:1 check-connection
Command failed with error: client error (Connect)
...
$ echo $?
0  # Should be non-zero

Fix: maybe return the error instead of swallowing it:

Some(cmd) => {
    dispatch(cmd.clone(), client.clone()).await?;  // Propagate error
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions