fix(cli): guard local-backend cwd resolution against a deleted CWD - #40161
Open
Dusk1e wants to merge 1 commit into
Open
fix(cli): guard local-backend cwd resolution against a deleted CWD#40161Dusk1e wants to merge 1 commit into
Dusk1e wants to merge 1 commit into
Conversation
load_cli_config() set terminal_config["cwd"] = os.getcwd() for the local backend. When the launch directory is deleted out from under the process, os.getcwd() raises FileNotFoundError, crashing CLI/TUI startup (and the gateway's lazy import of cli.py) before anything else runs. Reuse the existing tools.terminal_tool._safe_getcwd() helper, which falls back to TERMINAL_CWD then the home directory -- the same archetype already used in terminal_tool for this exact failure (commit ad69d3e). This keeps the resolved cwd consistent with the backend that consumes it. Adds regression tests exercising the real load_cli_config() with a deleted CWD (fall back to TERMINAL_CWD, then home).
Contributor
|
Thanks for the focused regression fix. The premise remains present on current main: The TUI slash worker imports Automated hermes-sweeper review. |
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.
What & Why
load_cli_config()setterminal_config["cwd"] = os.getcwd()for the localbackend with no guard. When the launch directory is deleted out from under the
process,
os.getcwd()raisesFileNotFoundError, crashing CLI/TUI startup —and the gateway's lazy import of
cli.py— before anything else runs.The fix reuses the existing
tools.terminal_tool._safe_getcwd()helper, whichfalls back to
TERMINAL_CWDthen the home directory. This is the same archetypealready used in
terminal_toolfor this exact failure (commitad69d3edc,"fix(terminal): guard os.getcwd() against a deleted CWD"), so the resolved cwd
stays consistent with the backend that consumes it.
How to test
Repro (before the fix): patch
os.getcwdto raiseFileNotFoundErrorand callcli.load_cli_config()— it crashes at the local-backend cwd line. After thefix it resolves to
TERMINAL_CWD, then home.Added regression tests in
tests/cli/test_cwd_env_respect.py(TestDeletedCwd)that exercise the real
load_cli_config()with a deleted CWD. They fail withoutthe fix and pass with it.