Skip to content

'defang cd refresh' without arguments is a silent no-op #2206

Description

@defangdevs

Description

defang cd refresh succeeds (exit 0) and does nothing when it is called without a PROJECT/STACK argument.

cdCommand (src/cmd/cli/command/cd.go) loops over args. With zero args, the loop body never runs and errors.Join() of an empty slice returns nil. The command prints nothing and exits 0, so the caller believes a refresh happened.

Every other PROJECT/STACK subcommand under cd declares Args: cobra.MinimumNArgs(1):

  • cd destroy — has it
  • cd down — has it
  • cd cancel — has it
  • cd outputs — has it
  • cd refresh — missing

The fix is one line: add Args: cobra.MinimumNArgs(1) to cdRefreshCmd. Alternatively, make the no-arg form load the project name from the local compose file and refresh the current stack, which matches what users probably expect. Either behavior is better than a silent success.

Steps to reproduce

defang cd refresh    # in any directory, with any provider configured
echo $?              # 0, nothing happened

Found while adding a manual-refresh workflow for s.defang.io (DefangLabs/s.defang.io PR 23, review comment r3771401029).

Activity

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

Metadata

Metadata

Assignees

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