fix(alias): report endpoint validation as usage errors#185
fix(alias): report endpoint validation as usage errors#185
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0795f6496
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This pull request ensures alias set endpoint validation failures are emitted as explicit usage errors in JSON mode so the JSON error payload’s code metadata matches the actual process exit status.
Changes:
- Emit alias endpoint validation failures via
formatter.error_with_code(ExitCode::UsageError, ...)to preserve JSONcode: 2. - Add an integration regression test ensuring
alias set --jsonrejects endpoints with embedded credentials without leaking or persisting secrets. - Add a small test helper to run the CLI with an isolated config directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/cli/src/commands/alias.rs |
Reports endpoint validation failures as explicit usage errors to keep JSON error metadata aligned with exit codes. |
crates/cli/tests/error_contract.rs |
Adds a regression test for the JSON error contract on embedded-credentials endpoints (and a config-isolated runner helper). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Related Issue
No linked issue. This follows recent alias endpoint validation work and adds a focused regression for a missed JSON error contract path.
Background
alias setnow rejects endpoint URLs that embed credentials, but JSON-mode validation errors should still be reported as usage errors with the same exit code metadata as the process exit status. Without an explicit usage code on this path, the JSON error payload can lose thecode: 2field and be inferred from the word "credentials" instead of from the command's actual usage error result.Solution
Emit endpoint validation failures through
error_with_code(ExitCode::UsageError, ...)so JSON error metadata matches the command's returned exit code. Add an integration regression that runsalias set --jsonwith credentials embedded in the endpoint and verifies the alias is rejected without persisting or echoing the secret.Validation
cargo test -p rustfs-cli --test error_contract alias_set_json_error_rejects_embedded_endpoint_credentials -- --nocapturecargo test -p rustfs-cli --test error_contractmake pre-commit