fix(cli): exit non-zero when configure receives invalid API URL - #3356
Open
Alan5168 wants to merge 1 commit into
Open
fix(cli): exit non-zero when configure receives invalid API URL#3356Alan5168 wants to merge 1 commit into
Alan5168 wants to merge 1 commit into
Conversation
…d API URL Previously, `hindsight configure --api-url <invalid>` printed an error but returned exit code 0 because the validation block called `print_error!` followed by `return Ok(())`. Scripts and CI pipelines relying on the exit code could not detect the failure. Replace the silent success with `anyhow::bail!` so the top-level error handler prints the message and exits with status 1, matching the behavior of every other CLI error path. Add two integration tests: - configure rejects URLs missing http(s):// with non-zero exit - configure accepts both http:// and https:// URLs
koriyoshi2041
approved these changes
Aug 11, 2026
koriyoshi2041
left a comment
Contributor
There was a problem hiding this comment.
Reviewed at 924aa3b1. Propagating the validation failure through anyhow::bail! gives the CLI the expected non-zero status while keeping the error on stderr. The added tests cover both rejection and the existing HTTP/HTTPS success paths. Local cargo test --test cli_profile passed, and git diff --check origin/main...HEAD is clean.
handnewb
approved these changes
Aug 11, 2026
handnewb
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Small focused fix — CLI should exit non-zero on configuration error, not silently return 0. Good test coverage with the new cli_profile test.
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.
Summary
hindsight configure --api-url <invalid>prints an error message but returns exit code 0. Scripts and CI pipelines relying on the exit status cannot detect the failure.Root cause
The URL validation block in
handle_configure()callsui::print_error!and thenreturn Ok(()), so the error is logged but the process exits successfully.Fix
Replace the silent success with
anyhow::bail!, which lets the top-level error handler print the message and exit with status 1 — consistent with every other error path in the CLI.Tests
Added two integration tests in
cli_profile.rs:configure_rejects_invalid_url_with_nonzero_exit— verifies exit code != 0 and error message on stderr for a URL missing the schemeconfigure_accepts_valid_http_and_https_urls— regression: bothhttp://andhttps://URLs still save successfullyAll 13 tests in
cli_profilepass:Scope
Only touches the configure command's URL validation. No change to URL parsing logic, config saving, or any other command.