fix: unset PKG_EXECPATH and stale broker token vars in startup-cleanup#152
Merged
benvinegar merged 1 commit intomainfrom Feb 24, 2026
Merged
fix: unset PKG_EXECPATH and stale broker token vars in startup-cleanup#152benvinegar merged 1 commit intomainfrom
benvinegar merged 1 commit intomainfrom
Conversation
Greptile SummaryFixes two environment variable inheritance bugs that prevented the Slack bridge from starting during mid-session restarts:
Both issues were introduced in #148 when Confidence Score: 5/5
Important Files Changed
Last reviewed commit: e58f2a6 |
…-cleanup When startup-cleanup.sh runs mid-session (called by the control agent), inherited env vars cause bridge startup failures: 1. PKG_EXECPATH — leaked from the parent varlock-launched process, causes varlock's SEA binary to misinterpret subcommands as Node module paths. The varlock broker-key probes (lines 115-122) silently fail, resulting in 'No Slack transport configured' and the bridge never starting. 2. varlock run does not override env vars already present in the parent process. If any managed value (broker tokens, API keys, config) was rotated after session start, the supervisor passes the stale values instead of reading fresh ones from ~/.config/.env. Fix: - unset PKG_EXECPATH at the script top (before varlock probes) - In the supervisor subshell, dynamically unset ALL varlock-managed keys via 'varlock load --format env' before calling 'varlock run', so every restart gets fresh values regardless of which keys changed. Regression from #148.
e58f2a6 to
302cf91
Compare
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.
Problem
PR #148 introduced
bridge-restart-policy.shsourcing and madestartup-cleanup.shthe canonical mid-session bridge restart path. Two classes of inherited env vars cause bridge startup failures when the script is called from a running control-agent session:Bug 1:
PKG_EXECPATHpoisons varlock probesThe pi agent process inherits
PKG_EXECPATHfrom its initial varlock launch. This causes varlock's SEA binary to misinterpretargv— treating subcommands likerunas Node module paths:The varlock broker-key probes on lines 115-122 fail silently (
2>/dev/null), soBRIDGE_SCRIPTstays empty → "No Slack transport configured" → bridge never starts.Bug 2: Stale env vars bypass varlock injection
varlock rundoes not override env vars already set in the parent process. This affects every varlock-managed variable, not just broker tokens. If any value is rotated after session start (broker token refresh, API key rotation, config change), the supervisor passes the stale inherited values instead of reading fresh ones from~/.config/.env.The original fix hardcoded
unsetfor justSLACK_BROKER_ACCESS_TOKENandSLACK_BROKER_ACCESS_TOKEN_EXPIRES_AT, but that's a whack-a-mole approach — any new rotatable credential would need another hardcodedunsetline.Fix
unset PKG_EXECPATHat the top of the script (line 14, before varlock probes)varlock load --format env --compactto enumerate every key varlock manages, then unsets them all beforevarlock runinjects fresh values:This guarantees every bridge restart gets fresh values from
~/.config/.env, regardless of which keys changed.Testing
bin/test.sh)PKG_EXECPATHset and staleSLACK_BROKER_ACCESS_TOKEN_EXPIRES_ATRegression from #148.