Skip to content

Fix exit code for postgres config patch / reset-password usage errors - #623

Open
sdairs wants to merge 1 commit into
fix/610-queries-file-multi-statementfrom
fix/613-postgres-usage-exit-codes
Open

Fix exit code for postgres config patch / reset-password usage errors#623
sdairs wants to merge 1 commit into
fix/610-queries-file-multi-statementfrom
fix/613-postgres-usage-exit-codes

Conversation

@sdairs

@sdairs sdairs commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

What

cloud postgres config patch with neither --set nor --file, and cloud postgres reset-password with neither --password nor --generate, exited 1 instead of the documented usage-error exit code 2.

Why

The "provide at least one of X or Y" checks lived in the handler as a runtime CloudError, so they went through the generic error path (exit 1) instead of clap's usage-error path (exit 2). config replace already gets this right because --file is a plain required field there.

Fix

Added ArgGroups (required(true)) over the existing conflicts_with pairs so clap itself enforces "at least one of":

  • PostgresCommands::ResetPassword: group over password / generate.
  • ConfigCommands::Patch: group over sets / file.

The handler-side checks are now unreachable through the CLI and were converted to debug_assert!/unreachable! safety nets, matching the existing pattern already used for the conflicts_with combination in postgres_reset_password.

Test plan

  • Added clap parse tests: rejects_postgres_config_patch_without_set_or_file and rejects_postgres_reset_password_without_password_or_generate, both asserting clap::error::ErrorKind::MissingRequiredArgument (which maps to exit code 2) and that the error message names both valid flags.
  • Confirmed existing valid-combination tests (--set, --file, --password, --generate, and the mutual-exclusion rejections) still pass.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p clickhousectl all clean.

Fixes #613

Note: this PR is part of a stacked chain — its base is fix/610-queries-file-multi-statement, not main.

🤖 Generated with Claude Code

@sdairs
sdairs force-pushed the fix/613-postgres-usage-exit-codes branch from 509d3b5 to 1fc6fa6 Compare August 28, 2026 14:46
`cloud postgres config patch` with neither --set nor --file, and
`cloud postgres reset-password` with neither --password nor --generate,
returned handler-side errors that exited 1 instead of the documented
usage-error exit code 2. Enforce the "at least one of" requirement with
clap ArgGroups (mirroring `config replace`'s existing required --file),
so clap itself raises the usage error. The now-unreachable handler-side
checks become debug_assert!/unreachable! safety nets.

Fixes #613

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sdairs
sdairs force-pushed the fix/613-postgres-usage-exit-codes branch from 1fc6fa6 to 12eb0f0 Compare August 28, 2026 19:42
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.

cloud postgres config patch / reset-password exit 1 instead of 2 on missing args

1 participant