Skip to content

voice-call plugin: config validation ignores environment variables #1709

@dguido

Description

@dguido

Summary

The voice-call plugin's validateProviderConfig() function checks for credentials in the config file but ignores environment variables, even though:

  1. The error messages claim env vars work: "(or set TWILIO_ACCOUNT_SID env)"
  2. The actual provider initialization (resolveProvider()) correctly falls back to env vars

This means users must put credentials in the config file even when env vars are set.

Expected Behavior

Setting TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN (or equivalent for other providers) as environment variables should satisfy the validation, matching what the error messages promise.

Actual Behavior

Validation fails with:

plugins.entries.voice-call.config.twilio.accountSid is required (or set TWILIO_ACCOUNT_SID env)

...even when TWILIO_ACCOUNT_SID is set in the environment.

Root Cause

In extensions/voice-call/src/runtime.ts:

  1. Line 100: validateProviderConfig(config) runs first - only checks config values
  2. Line 105: resolveProvider(config) runs after - this is where env vars are merged

The validation at step 1 doesn't know about the env var fallback that happens in step 2.

Code References

Validation (doesn't check env vars) - extensions/voice-call/src/config.ts:367-378:

if (config.provider === "twilio") {
  if (!config.twilio?.accountSid) {
    errors.push("...is required (or set TWILIO_ACCOUNT_SID env)");  // ← doesn't actually check env
  }
}

Provider init (does check env vars) - extensions/voice-call/src/runtime.ts:44-50:

case "twilio":
  return new TwilioProvider({
    accountSid: config.twilio?.accountSid ?? process.env.TWILIO_ACCOUNT_SID,  // ← env fallback here
    authToken: config.twilio?.authToken ?? process.env.TWILIO_AUTH_TOKEN,
  }, ...);

Suggested Fix

Update validateProviderConfig() to check both config AND env vars:

if (config.provider === "twilio") {
  if (!config.twilio?.accountSid && !process.env.TWILIO_ACCOUNT_SID) {
    errors.push("...");
  }
  if (!config.twilio?.authToken && !process.env.TWILIO_AUTH_TOKEN) {
    errors.push("...");
  }
}

Same pattern applies to Telnyx and Plivo providers.

Workaround

Add credentials directly to the config file instead of relying on env vars:

"voice-call": {
  "config": {
    "twilio": {
      "accountSid": "AC...",
      "authToken": "..."
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions