Fix: expand env var references in config.ts for webhook handler#6
Merged
Conversation
The slack-poller had expandEnvVars (added in d6d87b0) but config.ts did not. The webhook route handler uses config.ts, so trigger fields like slackBotToken: "${ELI_SLACK_BOT_TOKEN}" were passed as the literal string to the Slack API, causing invalid_auth on every failed session reply for Eli triggers.
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.
Root Cause
The
expandEnvVars()function was added toslack-poller.tsin commit d6d87b0 but never toconfig.ts. The webhook route handler (src/app/api/webhooks/slack/route.ts) usesconfig.tsto load trigger configs, so fields likeslackBotToken: "${ELI_SLACK_BOT_TOKEN}"were passed as the literal string${ELI_SLACK_BOT_TOKEN}to the Slack API instead of the resolved token value, causinginvalid_auth.This only surfaced for Eli triggers when a session failed (stalled), because the failure notification code path bypasses the
replyInThread: falseguard. Non-failed Eli sessions returned early and never hit the Slack API.Fix
Export
expandEnvVars()fromconfig.tsand apply it inloadTriggersConfig()so all consumers (webhook route handler, trigger lookups) get properly expanded env var values.Alert Reference
Triggered by production alert at 2026-06-22T16:45:03.953Z:
[Slack Webhook] Slack reply failed: invalid_auth thread_ts=1782146492.253349Session 6595e64a for trigger "alerts-infrastructure-dev-eli" in channel C0A83SHMC6R.
Testing
expandEnvVars(strings, nested objects, arrays, unset vars, realistic trigger configs)tsc --noEmit)