Skip to content

self-hosted build indexer cannot fetch project env vars with runtime environment key and aborts local deployment build #3258

@flowq-C

Description

@flowq-C

Summary

In self-hosted Trigger.dev local deployments, the build image indexer (managed-index-controller) fetches project environment variables during the Docker build stage. In our setup this call fails and aborts the entire deployment build.

Proven behavior

  • Docker build fails inside:
    • managed-index-controller.mjs
  • Error:
    • Failed to fetch environment variables: 403 Forbidden
  • Direct API probe against:
    • GET /api/v1/projects/:projectRef/envvars
  • Response with production runtime key (tr_prod_...):
    • 401 Invalid or Missing API key

Why this is a Trigger.dev self-hosted bug

  • The build pipeline passes TRIGGER_SECRET_KEY into the image build.
  • The indexer depends on fetching env vars during the build.
  • The supplied key path does not authenticate successfully against the envvars endpoint in self-hosted mode.
  • Result: deployment image build hard-fails before publish.

Repro

  1. Self-host Trigger.dev v4 with local builds enabled
  2. Run trigger.dev deploy
  3. Let build reach the managed-index-controller step
  4. Observe failure on env var fetch

Expected

  • Build-stage env var fetch succeeds with the provided deployment/build auth
  • or the indexer degrades gracefully and continues with an empty env set

Actual

  • Build aborts with:
    • Failed to fetch environment variables: 403 Forbidden

Evidence

  • Build log excerpt:
    • Failed to index deployment
    • message: 'Failed to fetch environment variables: 403 Forbidden'
  • Direct endpoint probe:
    • GET /api/v1/projects/proj_ncohokyumnepswndlhei/envvars
    • with tr_prod_...
    • returns 401 Invalid or Missing API key

Suggested fix

  • Use the correct auth token type for build-time envvar resolution
  • or make managed-index-controller non-fatal when envvar fetch fails

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