Skip to content

fix(sdk): resolve ReferenceError in envvars.update outside task conte…#4265

Closed
Rehansanjay wants to merge 1 commit into
triggerdotdev:mainfrom
Rehansanjay:fix/envvars-update-out-of-task-context
Closed

fix(sdk): resolve ReferenceError in envvars.update outside task conte…#4265
Rehansanjay wants to merge 1 commit into
triggerdotdev:mainfrom
Rehansanjay:fix/envvars-update-out-of-task-context

Conversation

@Rehansanjay

Copy link
Copy Markdown

…xt (#4264)

Closes #

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

[Describe the steps you took to test this change]


Changelog

[Short description of what has changed]


Screenshots

[Screenshots]

💯

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d2221fa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions

Copy link
Copy Markdown
Contributor

Hi @Rehansanjay, 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 Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a6fdeeae-888e-4a6f-bc57-9c48324f9d8d

📥 Commits

Reviewing files that changed from the base of the PR and between 2aa6420 and d2221fa.

📒 Files selected for processing (2)
  • packages/trigger-sdk/src/v3/envvars.ts
  • packages/trigger-sdk/src/v3/triggerClient.types.test.ts

Walkthrough

The environment variable update implementation now checks that non-task-context names are strings before assigning them, throwing an error otherwise. A type-level test verifies that client.envvars.update remains callable with both the four-argument out-of-task signature and the two-argument in-task signature.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 found 2 potential issues.

Open in Devin Review

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.

🔍 Pre-existing bug in the task-context branch assigns slug to projectRef

When taskContext.ctx is truthy and slugOrParams is a string (the 5-arg overload path), line 308 sets $projectRef = slugOrParams instead of $projectRef = projectRefOrName. This means the slug value gets used as the project reference. Line 309 then sets $slug = slugOrParams ?? taskContext.ctx.environment.slug which is correct in value but the ?? is dead code since slugOrParams is already confirmed to be a string (and thus truthy) by the typeof check on line 307.

This means that calling envvars.update("proj_ref", "dev", "MY_VAR", { value: "x" }) from inside a task context would send the API request with projectRef="dev" and slug="dev" instead of projectRef="proj_ref" and slug="dev". The PR fixes the analogous issue in the else branch but leaves this bug untouched.

(Refers to lines 308-309)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

🔍 Missing changeset for public package modification

The AGENTS.md requires adding a changeset when modifying any public package (packages/*). This PR modifies packages/trigger-sdk/src/v3/envvars.ts but the .changeset/ directory only contains README.md and config.json (no changeset file). This should be added before merge per repository conventions.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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