fix(hooks): use hardcoded expanduser path in python3 always_on checks#152
Open
xiaolai wants to merge 1 commit intotanweai:mainfrom
Open
fix(hooks): use hardcoded expanduser path in python3 always_on checks#152xiaolai wants to merge 1 commit intotanweai:mainfrom
xiaolai wants to merge 1 commit intotanweai:mainfrom
Conversation
failure-detector.sh and frustration-trigger.sh both used:
python3 -c "...open('$PUA_CONFIG')..."
$PUA_CONFIG is interpolated into the Python source string at the shell
level. A config path containing a single quote or other shell-special
characters would silently break the expression (syntax error), causing
the hooks to default to 'True' / always-on even when the user has
disabled PUA via /pua:off.
Fix: use os.path.expanduser('~/.pua/config.json') with a hardcoded path,
eliminating the interpolation entirely. This matches the safe pattern
already used in stop-feedback.sh and session-restore.sh.
Co-Authored-By: Claude Code <noreply@anthropic.com>
This was referenced Apr 26, 2026
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's broken
hooks/failure-detector.sh(line 10) andhooks/frustration-trigger.sh(line 8) both check whether PUA is enabled with:$PUA_CONFIGis interpolated into the Python source string at the shell level. If a user's$HOMEpath contains a single quote (e.g./home/o'malley) or other shell-special characters, the Python expression becomes a syntax error. Because the2>/dev/nullswallows the error and|| echo "True"provides the fallback, the hook silently assumesalways_on=True— meaning/pua:offhas no effect for those users.Fix
Replace the interpolated path with
os.path.expanduser('~/.pua/config.json')using a hardcoded tilde. This is the same pattern already used safely instop-feedback.shandsession-restore.sh:ALWAYS_ON=$(python3 -c "import os,json; print(json.load(open(os.path.expanduser('~/.pua/config.json'))).get('always_on', True))" 2>/dev/null || echo "True")One-line change per file; zero behavioral change for users with standard home directories.