Skip to content

CLI commands return exit 0 after printing Error to stderr #30

@arcavenai

Description

@arcavenai

Summary

Several marvel CLI commands print Error: ... to stderr but return exit code 0. Shell scripts and CI pipelines that key off exit codes will miss the failure.

Observed

marvel work with preflight failure

$ marvel --cluster desk work /tmp/preflight.yaml; echo "exit: $?"
Error: runtime pre-flight failed on 1 role(s):
  team[0=broken].role[0=ghost]: command "/nonexistent/binary": not found: stat /nonexistent/binary: no such file or directory
Usage:
  marvel work <manifest.toml> [flags]
...
exit: 0

marvel events against a daemon that doesn't expose the RPC

A pre-PR #25 daemon responds with Error: unknown method: events — but:

$ marvel events -n 5; echo "exit: $?"
Error: unknown method: events
Usage: ...
exit: 0

Expected

Exit code non-zero (idiomatically 1) when the command prints Error:. The Usage trailer after Error: suggests cobra's default error handling is routing through SilenceUsage: false but swallowing the return.

Likely cause

cobra's RunE returning an error should propagate to exit 1 via cmd.Execute() in cmd/marvel/main.go. Either:

  1. main.go isn't checking Execute()'s return
  2. A command is printing the error itself and returning nil
  3. SilenceErrors/SilenceUsage interaction is masking it

Test

After fix: marvel work /tmp/nonexistent-manifest.yaml; echo $? should print a non-zero code.

Environment

  • marvel 0.1.0-alpha.20260419.014522.b8f1f4b (commit b8f1f4b)
  • Linux aarch64, both mrvl:// and Unix socket paths reproduce

Metadata

Metadata

Assignees

No one assigned

    Labels

    area.clicmd/marvelpriority.p2Medium — should address this sprinttriage.newJust arrived, not yet reviewedtype.bugBroken behavior — something doesn't work as designed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions