fix(subdirectory-hints): avoid crash when HOME is unavailable - #50926
Closed
infinitycrew39 wants to merge 2 commits into
Closed
fix(subdirectory-hints): avoid crash when HOME is unavailable#50926infinitycrew39 wants to merge 2 commits into
infinitycrew39 wants to merge 2 commits into
Conversation
…is missing Path.expanduser() can raise RuntimeError in restricted service environments where HOME is unavailable. That error bubbled out of SubdirectoryHintTracker, interrupting tool-call execution. Treat this the same as other path-resolution failures and skip the candidate path instead of crashing the turn.
…HOME
Add a regression test that forces Path.expanduser() to raise
RuntimeError('Could not determine home directory.') and verifies
check_tool_call() returns safely instead of crashing.
Contributor
|
Fixed on main via #56355, which salvaged @udatny's #29433 — the earliest of three PRs fixing this exact bug (catch Merge commit: 55c8b2c |
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 happened
In restricted service environments (cron/systemd/container),
Path.expanduser()can raise:RuntimeError: Could not determine home directory.When that happened inside
SubdirectoryHintTracker._add_path_candidate(), it bubbled out and interrupted tool-call execution.Why this is a bug
Subdirectory hints are best-effort context enrichment. They should never crash the agent/tool path when a path token cannot be resolved.
Fix
Treat
RuntimeErrorfromPath.expanduser()the same as existing path-resolution errors (OSError,ValueError) and skip that candidate path.Tests
Added regression test in
tests/agent/test_subdirectory_hints.pyto forcePath.expanduser()to raiseRuntimeError("Could not determine home directory.")and verifycheck_tool_call()returns safely.Commits
fix(subdirectory-hints): ignore expanduser runtime failure when HOME is missingtest(subdirectory-hints): cover expanduser RuntimeError with missing HOME