Description
hooks/_lib/session_metrics.py:35 still uses a bare bracket access:
log_file = os.environ["VIBEGUARD_LOG_FILE"]
PR #93 fixed the same class of bug for VIBEGUARD_PROJECT_LOG_DIR (line 163) and VIBEGUARD_SESSION_ID (line 39) by switching to .get() with an early sys.exit(0), but VIBEGUARD_LOG_FILE was left unchanged. When the script is invoked standalone — without this env var exported — it raises a noisy KeyError: 'VIBEGUARD_LOG_FILE' Python traceback instead of silently exiting.
The unit test file tests/unit/test_session_metrics_env_guard.sh always supplies VIBEGUARD_LOG_FILE in every test case (see line ~50 VIBEGUARD_LOG_FILE="${TMPDIR_TEST}/events.jsonl"), so this code path has never been exercised by the test suite.
File reference
hooks/_lib/session_metrics.py:35
Recommended action
Replace line 35 with:
log_file = os.environ.get("VIBEGUARD_LOG_FILE", "")
if not log_file:
sys.exit(0)
Then add a test case to tests/unit/test_session_metrics_env_guard.sh that runs the script with VIBEGUARD_LOG_FILE unset and asserts exit code 0 with empty stdout (matching the guard pattern for VIBEGUARD_PROJECT_LOG_DIR at line 163).
Description
hooks/_lib/session_metrics.py:35still uses a bare bracket access:PR #93 fixed the same class of bug for
VIBEGUARD_PROJECT_LOG_DIR(line 163) andVIBEGUARD_SESSION_ID(line 39) by switching to.get()with an earlysys.exit(0), butVIBEGUARD_LOG_FILEwas left unchanged. When the script is invoked standalone — without this env var exported — it raises a noisyKeyError: 'VIBEGUARD_LOG_FILE'Python traceback instead of silently exiting.The unit test file
tests/unit/test_session_metrics_env_guard.shalways suppliesVIBEGUARD_LOG_FILEin every test case (see line ~50VIBEGUARD_LOG_FILE="${TMPDIR_TEST}/events.jsonl"), so this code path has never been exercised by the test suite.File reference
hooks/_lib/session_metrics.py:35Recommended action
Replace line 35 with:
Then add a test case to
tests/unit/test_session_metrics_env_guard.shthat runs the script withVIBEGUARD_LOG_FILEunset and asserts exit code 0 with empty stdout (matching the guard pattern forVIBEGUARD_PROJECT_LOG_DIRat line 163).