Skip to content

Fix: expand env var references in config.ts for webhook handler#6

Merged
crarau merged 1 commit into
mainfrom
fix/auto-config-expand-env-vars
Jun 22, 2026
Merged

Fix: expand env var references in config.ts for webhook handler#6
crarau merged 1 commit into
mainfrom
fix/auto-config-expand-env-vars

Conversation

@crarau

@crarau crarau commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Root Cause

The expandEnvVars() function was added to slack-poller.ts in commit d6d87b0 but never to config.ts. The webhook route handler (src/app/api/webhooks/slack/route.ts) uses config.ts to load trigger configs, so fields like slackBotToken: "${ELI_SLACK_BOT_TOKEN}" were passed as the literal string ${ELI_SLACK_BOT_TOKEN} to the Slack API instead of the resolved token value, causing invalid_auth.

This only surfaced for Eli triggers when a session failed (stalled), because the failure notification code path bypasses the replyInThread: false guard. Non-failed Eli sessions returned early and never hit the Slack API.

Fix

Export expandEnvVars() from config.ts and apply it in loadTriggersConfig() 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.253349
Session 6595e64a for trigger "alerts-infrastructure-dev-eli" in channel C0A83SHMC6R.

Testing

  • 9 new unit tests covering expandEnvVars (strings, nested objects, arrays, unset vars, realistic trigger configs)
  • Full test suite: 179 tests passing across 16 files
  • TypeScript clean (tsc --noEmit)

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.
@crarau
crarau merged commit fdc3d45 into main Jun 22, 2026
1 check passed
@crarau
crarau deleted the fix/auto-config-expand-env-vars branch June 22, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant