Skip to content

SST errors masked by RangeError: Invalid string length when secrets or resources are misconfigured #6300

@55Cancri

Description

@55Cancri

Description

When SST encounters certain errors (particularly missing secrets or AWS permission issues), the actual error message is hidden and users instead see:

RangeError: Invalid string length
    at markNodeModules (node:internal/util/inspect:1613:21)
    at formatError (node:internal/util/inspect:1747:18)
    ...
    at Object.defaultErrorMessage (.sst/platform/node_modules/@pulumi/cmd/run/error.ts:28:21)

This makes debugging very difficult because the actual error (e.g., "Secret EMAIL not set") is never shown.

Root Cause

This is actually a bug in Pulumi's error handling code. I've filed an issue there:

The bug is in @pulumi/pulumi/cmd/run/error.ts where util.inspect(err, { colors: true }) is called without error handling. AWS SDK errors (commonly triggered by SST) contain large metadata objects that cause util.inspect to crash.

Reproduction Steps

  1. Create a new SST project with an alert system that links to a secret:

    // infra/secrets.ts
    export const myEmail = new sst.Secret("EMAIL");
    
    // infra/alerts.ts
    alertQueue.subscribe({
      link: [myEmail],  // This will fail if EMAIL secret isn't set
      // ...
    });
  2. Do NOT set the secret:

    # Skip this step intentionally
    # sst secret set EMAIL your@email.com --stage dev
  3. Run sst dev or sst deploy

  4. Instead of "Secret EMAIL not set", you get RangeError: Invalid string length

Environment

  • SST: 3.17.25
  • Node.js: v24.11.1
  • OS: macOS arm64

Workaround

Until Pulumi fixes this upstream, you can:

  1. Check .sst/log/sst.log for the actual error
  2. Use this debug script to capture and parse Pulumi's event logs: [link to gist or script]

Suggested SST Improvement

While waiting for Pulumi to fix this, SST could:

  1. Document this known issue
  2. Add better pre-flight checks for common issues (missing secrets)
  3. Consider patching Pulumi's error handler as a post-install step

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions