Skip to content

Commit e58f2a6

Browse files
author
Baudbot
committed
fix: unset PKG_EXECPATH and stale broker token vars in startup-cleanup
When startup-cleanup.sh runs mid-session (called by the control agent), two 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. SLACK_BROKER_ACCESS_TOKEN / SLACK_BROKER_ACCESS_TOKEN_EXPIRES_AT — varlock does not override env vars already present in the parent process. If the broker token was rotated after session start, the supervisor passes the stale (expired) values instead of reading fresh ones from ~/.config/.env. Fix: unset PKG_EXECPATH at script top (before varlock probes), and unset broker token vars in the supervisor subshell (before varlock run). Regression from #148.
1 parent 94790e3 commit e58f2a6

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

pi/skills/control-agent/startup-cleanup.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
set -euo pipefail
1313

14+
# Prevent varlock SEA binary from misinterpreting argv when called from a
15+
# session that was itself launched via varlock (PKG_EXECPATH leaks into child
16+
# processes and causes `varlock run` to treat subcommands as Node module paths).
17+
unset PKG_EXECPATH 2>/dev/null || true
18+
1419
BRIDGE_POLICY_HELPER="$HOME/runtime/bin/lib/bridge-restart-policy.sh"
1520
if [ -r "$BRIDGE_POLICY_HELPER" ]; then
1621
# shellcheck source=bin/lib/bridge-restart-policy.sh
@@ -140,6 +145,11 @@ echo "Starting slack-bridge ($BRIDGE_SCRIPT) with PI_SESSION_ID=$MY_UUID..."
140145
mkdir -p "$BRIDGE_LOG_DIR"
141146
(
142147
unset PKG_EXECPATH
148+
# Clear stale broker token vars inherited from the parent session so that
149+
# varlock injects the current values from ~/.config/.env instead of passing
150+
# through an expired token/expiry from the original process environment.
151+
unset SLACK_BROKER_ACCESS_TOKEN
152+
unset SLACK_BROKER_ACCESS_TOKEN_EXPIRES_AT
143153
export PATH="$HOME/.varlock/bin:$HOME/opt/node/bin:$PATH"
144154
export PI_SESSION_ID="$MY_UUID"
145155
cd /opt/baudbot/current/slack-bridge

0 commit comments

Comments
 (0)