j: better error if JUMPSTARTER_HOST isn't set#739
Conversation
until now if j is called outside of a jmp shell, a ugly exception is thrown, this patch produces an error explaining what's going on.
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI Entry (j.py)
participant Env as Env Utils (env.py)
participant Util as Exception Utils (exceptions.py)
participant UI as Click Error (ClickExceptionRed)
User->>CLI: run CLI
CLI->>Env: load/validate environment
alt JUMPSTARTER_HOST missing
Env-->>CLI: raise EnvironmentVariableNotSetError (in ExceptionGroup)
CLI->>Util: find_exception_in_group(group, EnvironmentVariableNotSetError)
Util-->>CLI: returns matching exception
CLI->>UI: raise ClickExceptionRed with message (cause=group)
UI-->>User: show friendly error
else Environment present
CLI-->>User: continue execution
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Attention areas:
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings🧬 Code graph analysis (1)packages/jumpstarter-cli/jumpstarter_cli/j.py (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/jumpstarter/jumpstarter/common/exceptions.py (1)
78-81: Tiny docstring polish.
Consider changing “a environment” to “an environment” for grammar.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.py(1 hunks)packages/jumpstarter-cli/jumpstarter_cli/j.py(1 hunks)packages/jumpstarter/jumpstarter/common/exceptions.py(1 hunks)packages/jumpstarter/jumpstarter/utils/env.py(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mangelajo
Repo: jumpstarter-dev/jumpstarter PR: 610
File: packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.py:488-491
Timestamp: 2025-09-15T08:18:48.571Z
Learning: In the jumpstarter project, code review suggestions should stay focused on the specific scope of the PR. Suggestions about general improvements like timeout handling or error handling that are unrelated to the core changes being made should be avoided, even if they apply to modified code lines.
📚 Learning: 2025-10-02T15:29:09.070Z
Learnt from: mangelajo
Repo: jumpstarter-dev/jumpstarter PR: 681
File: packages/jumpstarter/jumpstarter/client/lease.py:198-220
Timestamp: 2025-10-02T15:29:09.070Z
Learning: In the jumpstarter codebase, `client_from_path` and `client_from_channel` functions in `packages/jumpstarter/jumpstarter/client/client.py` automatically call `GetReport(empty_pb2.Empty())` during client initialization. This means that successfully entering the client context manager guarantees the exporter is responsive and has answered the GetReport RPC.
Applied to files:
packages/jumpstarter/jumpstarter/utils/env.py
🧬 Code graph analysis (2)
packages/jumpstarter/jumpstarter/utils/env.py (1)
packages/jumpstarter/jumpstarter/common/exceptions.py (1)
EnvironmentVariableNotSetError(78-81)
packages/jumpstarter-cli/jumpstarter_cli/j.py (3)
packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.py (4)
ClickExceptionRed(11-13)async_handle_exceptions(16-39)find_exception_in_group(109-126)leaf_exceptions(130-154)packages/jumpstarter/jumpstarter/common/exceptions.py (1)
EnvironmentVariableNotSetError(78-81)packages/jumpstarter/jumpstarter/utils/env.py (2)
env(42-51)env_async(13-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: e2e
- GitHub Check: pytest-matrix (macos-15, 3.12)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.13)
- GitHub Check: pytest-matrix (macos-15, 3.13)
- GitHub Check: pytest-matrix (macos-15, 3.11)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.12)
- GitHub Check: Redirect rules - jumpstarter-docs
- GitHub Check: Header rules - jumpstarter-docs
- GitHub Check: Pages changed - jumpstarter-docs
🔇 Additional comments (2)
packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.py (1)
109-126: Helper reads cleanly.
Nice reuse ofleaf_exceptions; this keeps the exception-group plumbing tidy.packages/jumpstarter/jumpstarter/utils/env.py (1)
21-24: Good call on the explicit exception.
UsingEnvironmentVariableNotSetErrormakes the failure easier to catch up-stack.
kirkbrauer
left a comment
There was a problem hiding this comment.
I think this looks good, just might want to check the one CodeRabbbit suggestion to re-raise the exception in other non-special cases.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
yep!!!, @coderabbitai is awesome :) |
|
Tip For best results, initiate chat on the files or code changes. @mangelajo Thank you so much for the kind words! 🙏 I'm glad the suggestion about re-raising exceptions was helpful. It's important to ensure that unexpected exception types are propagated correctly so they aren't silently caught and masked. Looking forward to continuing to help improve the jumpstarter codebase! 🚀 🧠 Learnings used |
* j: better error if JUMPSTARTER_HOST isn't set until now if j is called outside of a jmp shell, a ugly exception is thrown, this patch produces an error explaining what's going on. * Raise exceptions not in group Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit 4402736)
|
Successfully created backport PR for |
until now if j is called outside of a jmp shell, a ugly exception is thrown, this patch produces an error
explaining what's going on.
Summary by CodeRabbit