Skip to content

fix(cli): stop reads only composeProjectName so a broken config can still stop the stack - #26

Merged
nicosampler merged 1 commit into
mainfrom
fix/stop-broken-config
Aug 3, 2026
Merged

fix(cli): stop reads only composeProjectName so a broken config can still stop the stack#26
nicosampler merged 1 commit into
mainfrom
fix/stop-broken-config

Conversation

@nicosampler

Copy link
Copy Markdown
Collaborator

Summary

Closes #25

stop validated the full config before shelling out to Docker Compose, so any
config error left a running stack that the tool could not bring down. Tearing
the stack down only needs the Compose project name, so stop now reads just
that field.

Changes

  • stop is dispatched before loadConfig() and tears the stack down with
    docker compose --project-name <name> down --remove-orphans, which finds the
    containers by project label without compose files, env files, or profiles.
  • New parseComposeProjectName (pure) and loadComposeProjectName in
    src/config.js: only composeProjectName is validated; everything else,
    including the version gate, is ignored.
  • New stopStackByProjectName in src/compose.js; the docker spawn logic is
    extracted into a shared runDocker helper reused by runDockerCompose.
  • README: stop removed from the config-reading commands in the lifecycle
    diagram, plus a note under CLI reference explaining the behavior.
  • Changeset (patch).

Acceptance criteria

Suggested from the issue's expected behavior (it has no formal AC list):

  • stop stops the stack when the config is broken but composeProjectName is a valid non-empty string
  • stop fails with the usual config error when composeProjectName is missing or invalid
  • Every other Docker command keeps validating the full config

Test plan

Automated tests

scripts/config-validation.test.js: 4 new cases for parseComposeProjectName
(valid config, config that full validation rejects, missing field, empty field).
Run with npm test (30 passing).

Manual verification

  1. With "version": 0 plus an unknown field and a valid composeProjectName,
    stop runs the compose down and exits 0.
  2. With composeProjectName empty or missing, stop prints the config error
    and exits 1.

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

@nicosampler nicosampler self-assigned this Aug 3, 2026
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@nicosampler
nicosampler merged commit a210900 into main Aug 3, 2026
3 checks passed
@nicosampler
nicosampler deleted the fix/stop-broken-config branch August 3, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stop fails when the config is invalid, leaving a running stack the tool cannot bring down

2 participants