Fix exit code for postgres config patch / reset-password usage errors - #623
Open
sdairs wants to merge 1 commit into
Open
Fix exit code for postgres config patch / reset-password usage errors#623sdairs wants to merge 1 commit into
sdairs wants to merge 1 commit into
Conversation
sdairs
force-pushed
the
fix/613-postgres-usage-exit-codes
branch
from
August 28, 2026 14:46
509d3b5 to
1fc6fa6
Compare
`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
force-pushed
the
fix/613-postgres-usage-exit-codes
branch
from
August 28, 2026 19:42
1fc6fa6 to
12eb0f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
cloud postgres config patchwith neither--setnor--file, andcloud postgres reset-passwordwith neither--passwordnor--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 replacealready gets this right because--fileis a plain required field there.Fix
Added
ArgGroups (required(true)) over the existingconflicts_withpairs so clap itself enforces "at least one of":PostgresCommands::ResetPassword: group overpassword/generate.ConfigCommands::Patch: group oversets/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 theconflicts_withcombination inpostgres_reset_password.Test plan
rejects_postgres_config_patch_without_set_or_fileandrejects_postgres_reset_password_without_password_or_generate, both assertingclap::error::ErrorKind::MissingRequiredArgument(which maps to exit code 2) and that the error message names both valid flags.--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 clickhousectlall clean.Fixes #613
Note: this PR is part of a stacked chain — its base is
fix/610-queries-file-multi-statement, notmain.🤖 Generated with Claude Code