fix: small fixes batch (#516, #525, #652, #517)#681
Conversation
The TODO claimed the debug flag needed forwarding to the uboot client, but it is already passed via debug=self._console_debug in both reboot_to_console() call sites. Closes jumpstarter-dev#516 Generated-By: Forge/20260513_094530_2089907_aa882926
Adds a user-friendly error message for the gRPC FAILED_PRECONDITION status code, matching the pattern of the five existing status code handlers in _map_grpc_exception. Closes jumpstarter-dev#652 Generated-By: Forge/20260513_094530_2089907_aa882926
These flags only apply to client configs. When used with an exporter config, they are silently ignored, which can confuse users. Now a warning is emitted explaining the flags have no effect. Closes jumpstarter-dev#525 Generated-By: Forge/20260513_094530_2089907_aa882926
Replaces the hardcoded retry count of 100 with a keyword argument retries=100, preserving backward compatibility while allowing callers to adjust the retry count. Closes jumpstarter-dev#517 Generated-By: Forge/20260513_094530_2089907_aa882926
…_console retries The existing tests only verified the function signature via inspect, which would pass even if the retries parameter were accepted but silently ignored in the loop body. Replace the redundant default-value test with a behavioral test that mocks serial.pexpect() to always timeout and asserts that exactly N ESC sends occur when retries=N, proving the parameter controls the loop. Generated-By: Forge/20260513_094530_2089907_aa882926 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add bool type annotation to debug parameter, success-path and retries=0 edge case tests for reboot_to_console, remove unused login import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR addresses four separate TODOs across the Jumpstarter codebase: handling gRPC FAILED_PRECONDITION errors with user-friendly messages, warning about incompatible login flags with exporter configurations, making U-Boot boot interrupt retries configurable, and cleaning up a deferred console debug propagation TODO. ChangesCLI Exception Handling: FAILED_PRECONDITION Mapping
Login Exporter/Client-Only Flag Warnings
U-Boot Retry Configurability
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (2)
python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client_test.py (1)
49-76: 💤 Low valueConsider using
0instead ofNonefor accurate pexpect behavior.The test mocks
expect_exactto returnNoneon successful match (line 54), but the realpexpect.expect_exact()returns the index of the matched pattern (which would be0for a single pattern). While the current implementation doesn't check the return value—soNoneworks—using0would more accurately simulate pexpect's actual behavior.🔍 More accurate mock
mock_pexpect_process.expect_exact = MagicMock( - side_effect=[pexpect.TIMEOUT("timeout"), pexpect.TIMEOUT("timeout"), None] + side_effect=[pexpect.TIMEOUT("timeout"), pexpect.TIMEOUT("timeout"), 0] )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client_test.py` around lines 49 - 76, The test's mock for pexpect.expect_exact in test_reboot_to_console_yields_on_prompt_match should return 0 instead of None to more accurately emulate pexpect (it returns the matched pattern index); update the side_effect in mock_pexpect_process.expect_exact (the list currently [pexpect.TIMEOUT("timeout"), pexpect.TIMEOUT("timeout"), None]) to use 0 for the successful match so the behavior of reboot_to_console and the assertions (mock_pexpect_process.send.call_count and mock_power.cycle) remain valid.python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client.py (1)
22-35: ⚡ Quick winDocument the new
retriesparameter in the docstring.The method signature now accepts a
retriesparameter with a default of 100, but the docstring does not mention it. Users need to know that this parameter controls how many boot-interrupt attempts are made before raisingRuntimeError.📝 Suggested docstring update
def reboot_to_console(self, *, debug: bool = False, retries: int = 100) -> Generator[None]: """ Reboot to U-Boot console Power cycle the target and wait for the U-Boot prompt Must be used as a context manager, other methods can only be used within the reboot_to_console context + + Args: + debug: Enable debug logging to stdout + retries: Maximum number of boot-interrupt attempts (default 100) >>> with uboot.reboot_to_console(debug=True): # doctest: +SKIP ... uboot.set_env("foo", "bar") ... uboot.setup_dhcp() >>> # uboot.set_env("foo", "baz") # invalid use """🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client.py` around lines 22 - 35, Update the reboot_to_console docstring to document the new retries parameter: state that reboot_to_console(self, *, debug: bool = False, retries: int = 100) accepts retries (int, default 100) which controls how many boot-interrupt/attempts are made waiting for the U-Boot prompt before raising RuntimeError; include brief guidance on when to increase it and that it only applies to the context-manager boot interrupt loop inside reboot_to_console.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client_test.py`:
- Around line 49-76: The test's mock for pexpect.expect_exact in
test_reboot_to_console_yields_on_prompt_match should return 0 instead of None to
more accurately emulate pexpect (it returns the matched pattern index); update
the side_effect in mock_pexpect_process.expect_exact (the list currently
[pexpect.TIMEOUT("timeout"), pexpect.TIMEOUT("timeout"), None]) to use 0 for the
successful match so the behavior of reboot_to_console and the assertions
(mock_pexpect_process.send.call_count and mock_power.cycle) remain valid.
In `@python/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client.py`:
- Around line 22-35: Update the reboot_to_console docstring to document the new
retries parameter: state that reboot_to_console(self, *, debug: bool = False,
retries: int = 100) accepts retries (int, default 100) which controls how many
boot-interrupt/attempts are made waiting for the U-Boot prompt before raising
RuntimeError; include brief guidance on when to increase it and that it only
applies to the context-manager boot interrupt loop inside reboot_to_console.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c34bd97d-4842-4da9-8c52-4200b899f8de
📒 Files selected for processing (7)
python/packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.pypython/packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions_test.pypython/packages/jumpstarter-cli/jumpstarter_cli/login.pypython/packages/jumpstarter-cli/jumpstarter_cli/login_test.pypython/packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.pypython/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client.pypython/packages/jumpstarter-driver-uboot/jumpstarter_driver_uboot/client_test.py
💤 Files with no reviewable changes (1)
- python/packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.py
set_console_debug-- the debug flag is already passed viadebug=self._console_debugat every call sitelogin.pywhen--allow/--unsafeare used with exporter config, since these flags only apply to client configsFAILED_PRECONDITIONcase to_map_grpc_exceptioninexceptions.py, matching the 5 existing status code handlersretrieskwarg (default 100) toreboot_to_console()in U-Boot clientCloses #516
Closes #525
Closes #652
Closes #517