Repository navigation
Fix hook crashing on every call under the host's Python 3.9 - #9
Merged
Merged
Conversation
log_artifact_entry.py uses PEP 604 union syntax (str | None, dict | None) in three function signatures, which requires evaluating annotations at def time on Python < 3.10. The Docker image is fine (python:3.12-slim), but the hook itself runs directly on the host via PostToolUse, and the CasaOS host's only python3 is 3.9.2 — so the hook has raised TypeError on every single invocation, in every project, since it was installed. Silent, because hook stderr isn't surfaced anywhere visible. `from __future__ import annotations` defers annotation evaluation to strings, which fixes all three signatures with no syntax rewrite and no host Python upgrade needed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 of 2 tasks
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.
Summary
Diagnosed via a handoff from a prior debugging session on the CasaOS host: no data was reaching Mongo/
:8743despite the hook being installed and finance-agent producing artifacts. Two independent bugs, this PR fixes the first.log_artifact_entry.pyuses PEP 604 union syntax (str | None,dict | None) in three signatures (render,find_project_root,build_entry). This requires Python 3.10+ to evaluate atdeftime. The Docker image is unaffected (python:3.12-slim), but the hook runs directly on the host via~/.claude/settings.json'sPostToolUse(python3 ~/.claude/hooks/log_artifact_entry.py) — and the host's onlypython3is 3.9.2. Result:TypeErroron every single invocation, in every project, since install — silent, since hook stderr isn't surfaced anywhere visible.from __future__ import annotationsas the first import, deferring annotation evaluation to strings. No syntax rewrite, no host Python upgrade needed. Confirmed no other 3.10+ constructs exist in the file (only those three annotations use|; nomatchstatements; allisinstancecalls use plain builtin types).A second, independent bug from the same handoff — finance-agent never had a
.ai-data-store.jsonto opt in — is fixed separately in agb1986/finance-agent#13, since that config lives in finance-agent's own repo.Test plan
ruff check .— cleanpytest— 57 passedcasaos). After merge, on the host:git pull cp hooks/log_artifact_entry.py ~/.claude/hooks/log_artifact_entry.py:8743), and clean up the test doc/tmp file afterward.🤖 Generated with Claude Code