t1034: Fix PULSE_LOCK_DIR unbound variable — t1031 modularisation regression#1373
t1034: Fix PULSE_LOCK_DIR unbound variable — t1031 modularisation regression#1373marcusquinn merged 1 commit intomainfrom
Conversation
…ion) The t1031 modularisation left PULSE_LOCK_DIR, SUPERVISOR_DIR, and other globals defined AFTER the module source block. With set -euo pipefail, any function or trap referencing these variables hit 'unbound variable' errors. This broke the cron pulse — no tasks were dispatched since t1031 merged. Fix: define all globals before sourcing modules.
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical regression that emerged from a previous modularization effort. The issue caused cron pulses to fail due to an 'unbound variable' error, effectively halting task dispatch. The fix involves a strategic reordering of global variable declarations within the main supervisor script, ensuring that all essential variables are properly defined and accessible before any modules that rely on them are sourced. This change restores the stability and functionality of the cron pulse mechanism. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Feb 13 14:38:38 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
WalkthroughReorganized global variable declarations in a shell script to initialize and export them before sourcing modules, rather than after. This prevents unbound variable errors in strict mode by ensuring dependencies are available when modules are loaded. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an 'unbound variable' regression by reordering global variable definitions to occur before modules that depend on them are sourced. The change is logical and well-explained. I have one suggestion regarding error handling during directory creation to improve the script's robustness by adhering more closely to the repository's style guide.
| readonly SESSION_CHECKPOINT_HELPER="${SCRIPT_DIR}/session-checkpoint-helper.sh" # Used by respawn (t264.1) | ||
| readonly RESPAWN_LOG="${HOME}/.aidevops/logs/respawn-history.log" # Persistent respawn log (t264.1) | ||
| SUPERVISOR_LOG_DIR="${HOME}/.aidevops/logs" | ||
| mkdir -p "$SUPERVISOR_LOG_DIR" 2>/dev/null || true |
There was a problem hiding this comment.
This line suppresses all errors from mkdir -p, including critical ones like permission denied. If mkdir -p fails, the script will continue silently due to || true, but will likely fail later when trying to write to the log file, making the root cause harder to debug.
This violates the repository style guide:
- Line 13:
|| trueguards are intended for commands likegrepthat can "fail" in normal operation, not formkdirwhere a failure is a genuine error. - Line 50:
2>/dev/nullis used for blanket suppression, which is disallowed.
Removing the error suppression will allow set -e to correctly halt the script on a legitimate directory creation failure, making it more robust.
| mkdir -p "$SUPERVISOR_LOG_DIR" 2>/dev/null || true | |
| mkdir -p "$SUPERVISOR_LOG_DIR" |
References
- Use
|| trueguards only for commands that are expected to fail during normal execution underset -e, likegrepwith no matches or arithmetic evaluations.mkdirfailing is a genuine error. (link) - Error stream redirection to
/dev/nullis only acceptable when redirecting to log files, not for blanket suppression of potential errors. (link)



Summary
SUPERVISOR_DIR,PULSE_LOCK_DIR,SUPERVISOR_DB, etc.) before the modulesourceblock insupervisor-helper.shPULSE_LOCK_DIR: unbound variableerrors underset -euo pipefailRoot Cause
supervisor-helper.shhasset -euo pipefail. The modulesourceblock was at lines 170-187, but globals likePULSE_LOCK_DIRwere defined at line 202. Whenrelease_pulse_lock()(inutility.sh) was called via EXIT trap in subshells, the variable wasn't in scope, producing the unbound variable error.Fix
Move the entire globals block (lines 189-205) to before the module source block (now lines 167-188). No functional change — just reordering declarations.
Verification
bash -nsyntax check passesshellcheck -S errorcleansupervisor-helper.sh helploads correctly~/.aidevops/agents/scripts/— next cron pulse will verifyCloses #1372
Summary by CodeRabbit