fix(cli): raise on explicit --profile resolution failure instead of silent localhost fallback#414
Open
Chaffelson wants to merge 1 commit into
Open
fix(cli): raise on explicit --profile resolution failure instead of silent localhost fallback#414Chaffelson wants to merge 1 commit into
Chaffelson wants to merge 1 commit into
Conversation
…ilent localhost fallback An explicit `--profile` whose resolution failed was swallowed by a bare `except ValueError: pass`, leaving the SDK on its default localhost endpoint. The user then hit a confusing localhost connection error on the first API call instead of the real cause (missing/misconfigured profile). Extract profile application into `_apply_profile()`: an explicit `--profile` failure now emits a structured error and exits non-zero, while auto-resolution (no `--profile` given) still falls through so configuration errors surface on the first API call, preserving the just-works-without-config behaviour. Adds unit tests for the explicit-failure, auto-resolve, and success paths.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #414 +/- ##
==========================================
+ Coverage 77.12% 77.22% +0.09%
==========================================
Files 41 41
Lines 4954 4962 +8
==========================================
+ Hits 3821 3832 +11
+ Misses 1133 1130 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ottobackwards
requested changes
Jul 22, 2026
|
|
||
| try: | ||
| nipyapi.profiles.switch(explicit_profile) | ||
| except ValueError as e: |
Collaborator
There was a problem hiding this comment.
why check for none after making a call? Would it be better to move this check outside the try block?
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
An explicit
--profilewhose resolution failed was swallowed by a bareexcept ValueError: passin the CLI entry point, leaving the SDK on its defaultlocalhost:9443endpoint. Users then hit a confusing localhost connection error on the first API call instead of the real cause — a missing or misconfigured profile.This extracts profile application into a small
_apply_profile()helper:--profilethat fails to resolve now emits a structured error naming the profile and exits non-zero.--profilegiven) still falls through, so configuration errors surface on the first API call — preserving the just-works-without-config behaviour.Test plan
make lint— 10.00/10make test NIPYAPI_PROFILE=single-user PYTEST_ARGS="-v tests/test_cli.py"— 96 passed (adds 3 unit tests: explicit-failure, auto-resolve, success paths)