Skip to content

fix(sdk): resolve ReferenceError and projectRef in envvars.update (#4264) - #4968

Closed
kaiizer777 wants to merge 1 commit into
triggerdotdev:mainfrom
kaiizer777:fix/sdk-envvars-update-name
Closed

kaiizer777 wants to merge 1 commit into
triggerdotdev:mainfrom
kaiizer777:fix/sdk-envvars-update-name

Conversation

@kaiizer777

Copy link
Copy Markdown

Resolves #4264

Root Cause

In packages/trigger-sdk/src/v3/envvars.ts, the implementation function parameter is named nameOrRequestOptions, but the out-of-task execution branch at line 341 assigned $name = name!;. Because name was not in scope, running envvars.update(projectRef, slug, name, params) from Node outside of a task context threw ReferenceError: name is not defined.
Additionally, in the in-task 4-argument branch (update(projectRef, slug, name, params)), $projectRef was assigned from slugOrParams instead of projectRefOrName, which caused the environment slug to be substituted for the project reference in the API request path (/api/v1/projects/<slug>/... instead of /api/v1/projects/<projectRef>/...).

Changes

  • In packages/trigger-sdk/src/v3/envvars.ts:
    • Assigned $name = nameOrRequestOptions; in the out-of-task branch, resolving the ReferenceError.
    • Added explicit validation requiring typeof nameOrRequestOptions === "string" in both task and non-task 4-argument branches, throwing "name is required" if missing.
    • Assigned $projectRef = projectRefOrName; in the in-task 4-argument branch to ensure the correct project reference is used in the API request path.
  • Added comprehensive unit tests in packages/trigger-sdk/src/v3/envvars.test.ts testing:
    • Outside task context: successful 4-argument update, validation errors when slug, name, or params are missing.
    • Inside task context: 2-argument update deriving project.ref and environment.slug from context, 4-argument update preserving explicit projectRef, slug, and name, and validation for missing name and params.
  • Added patch changeset targeting @trigger.dev/sdk.

Note

A vouch request for CI/contributions is open at #4963.

@changeset-bot

changeset-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 85a28b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/sdk Patch
@trigger.dev/python Patch
@internal/dashboard-agent Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/core Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@trigger.dev/sso Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@internal/tracing Patch
@internal/webhook-engine Patch
@internal/webhook-sources Patch
@internal/testcontainers Patch
@internal/cache Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kaiizer777

Copy link
Copy Markdown
Author

Vouch request is open at #4963. Ready for review once vouched!

@github-actions

Copy link
Copy Markdown
Contributor

Hi @kaiizer777, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c3539f2c-2353-41ea-bc24-f1d884cdcf9b

📥 Commits

Reviewing files that changed from the base of the PR and between d8c3530 and 85a28b1.

📒 Files selected for processing (3)
  • .changeset/fix-envvars-update-name.md
  • packages/trigger-sdk/src/v3/envvars.test.ts
  • packages/trigger-sdk/src/v3/envvars.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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.

bug: envvars.update() throws "ReferenceError: name is not defined" outside a task context

1 participant