Skip to content

--quiet hides the error message when a command fails #2876

Open

Description

@oceans404

What's wrong:
With -q / --quiet, a failing command exits 1 and prints nothing: no error on stderr and nothing on stdout. For example, with CLI 28.1.0:

$ stellar -q tx sign --sign-with-key nobody --network-passphrase "Test SDF Network ; September 2015" < tx.xdr
$ echo $?
1

Without -q the same command prints ❌ error: .... The flag's help says it means "Do not write logs to stderr including INFO" (v28.1.0 global.rs#L27-L29), but the final error line goes through the same quiet-aware printer as the progress lines (v28.1.0 cli.rs#L106, printer.errorln(format!("error: {e}"))). Before #1584 (September 2024, about contract init error handling) the error was always written with eprintln!; that PR moved it to the printer.

Impact:
-q is what scripts and agents use to drop the progress lines (for example LATCH passes --quiet on every call), so it's the mode where a readable failure matters most. Under -q the only signal is the exit code, so a script or a coding agent can't tell a missing identity from a network error or a contract failure, and logs show nothing to debug.

How we found it:
While checking how scripts and agents drive the CLI, as part of a review of HackMeridian 2026 hackathon repos (147 public repos) against CLI 28.1.0. Reproduced with the 28.1.0 release binary on 1 November 2026. Some repos wrap every CLI call in --quiet (for example LATCH scripts/testnet/bootstrap.mjs#L70-L72), so any failure there surfaces only as an exit code.

Outcome we're after:
When a command fails under -q, the reason is still available to the caller. How to get there is up to the implementer.

Compatibility: Successful runs under -q should stay as quiet as today, and exit codes shouldn't change.

How to check:

  • stellar -q tx sign --sign-with-key nobody ... < tx.xdr exits 1 and the reason is available.
  • A successful stellar -q contract deploy ... still prints only the contract ID.
  • Commands that already emit JSON errors with --output json behave as before.

Related: #2622 (structured output and errors), #2635 (JSON error output for commands with --output json, which still works under -q), #1840 and #2300 (-q also silences the detailed tx sign output), #1971 (closed; alias ls info lines on stdout ignore -q).

Activity

  1. moved this to Backlog (Not Ready) in DevXon Nov 1, 2026
  2. sinescribe commented on Nov 20, 2026

    @sinescribe

    Hi @oceans404! I traced why -q / --quiet swallows fatal command errors and have a minimal fix ready for a PR:

    Root Cause

    1. In cmd/soroban-cli/src/cli.rs:106, top-level command errors are printed via printer.errorln(format!("error: {e}")) before std::process::exit(1).
    2. In cmd/soroban-cli/src/print.rs:88-104, error and errorln are generated by the create_print_functions! macro, which gates output behind if !self.quiet:
    pub fn $nameln<T: Display + Sized>(&self, message: T) {
        if !self.quiet {
            eprintln!("{} {}", self.compute_emoji($icon), message);
        }
    }

    Because --quiet is documented as "Do not write logs to stderr including INFO" (global.rs#L27-L29), gating error / errorln behind !self.quiet causes fatal errors on non-JSON failure paths to exit 1 with empty stderr.

    Proposed Fix

    Decouple error and errorln from create_print_functions! in cmd/soroban-cli/src/print.rs so fatal errors are always written to stderr regardless of self.quiet:

    impl Print {
        pub fn error<T: Display + Sized>(&self, message: T) {
            eprint!("{} {}", self.compute_emoji("❌"), message);
        }
    
        pub fn errorln<T: Display + Sized>(&self, message: T) {
            eprintln!("{} {}", self.compute_emoji("❌"), message);
        }
    }
    • stellar -q tx sign --sign-with-key nobody ... < tx.xdr exits 1 and prints ❌ error: ... to stderr.
    • Successful stellar -q ... runs stay completely silent on stderr.
    • --output json error handling in cli.rs continues to run before printer.errorln and remains unchanged.

    Happy to open a PR with an integration test covering -q on failing and succeeding invocations!

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

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions