Skip to content

fix(sdk): resolve ReferenceError in envvars.update() outside task con… - #4920

Closed
mahenoorsalat wants to merge 1 commit into
triggerdotdev:mainfrom
mahenoorsalat:fix/4264-envvars-update-outside-task
Closed

fix(sdk): resolve ReferenceError in envvars.update() outside task con…#4920
mahenoorsalat wants to merge 1 commit into
triggerdotdev:mainfrom
mahenoorsalat:fix/4264-envvars-update-outside-task

Conversation

@mahenoorsalat

@mahenoorsalat mahenoorsalat commented Sep 11, 2026

Copy link
Copy Markdown

…text (#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 Sep 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 946e812

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

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 823fe5ee-9d0c-4b24-95af-5256ad001e17

📥 Commits

Reviewing files that changed from the base of the PR and between 478422f and 946e812.

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

Walkthrough

The change adds validation for the name argument in the non-task-context envvars.update path. It also adds tests that verify the PUT request URL, method, bearer token, serialized body, and required argument errors. The tests isolate API client and task context state and restore the fetch spy after each test.

✨ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @mahenoorsalat, 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 11, 2026

@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 3 potential issues.

Devin Review

Comment on lines +335 to +337
if (typeof nameOrRequestOptions !== "string") {
throw new Error("name is required");
}

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.

🟡 Empty variable names bypass validation

An empty nameOrRequestOptions passes validation and sends update to an endpoint without a variable name. The update fails as an HTTP routing error.

Suggested change
if (typeof nameOrRequestOptions !== "string") {
throw new Error("name is required");
}
if (!nameOrRequestOptions || typeof nameOrRequestOptions !== "string") {
throw new Error("name is required");
}
Devin Review

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

Comment on lines +335 to +345
if (typeof nameOrRequestOptions !== "string") {
throw new Error("name is required");
}

if (!params) {
throw new Error("params is required");
}

$projectRef = projectRefOrName;
$slug = slugOrParams;
$name = name!;
$name = nameOrRequestOptions;

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.

🔍 SDK fix lacks a changeset

This user-visible @trigger.dev/sdk runtime fix has no changeset. Repository guidance requires release notes for package bugs customers can encounter.

Devin Review

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

Comment on lines +17 to +36
globalThis.fetch = (async (input: any, init?: RequestInit) => {
const url = typeof input === "string" ? input : (input?.url ?? String(input));
const headers = new Headers(init?.headers);
captured.push({
url,
method: init?.method,
authorization: headers.get("authorization") ?? undefined,
body: typeof init?.body === "string" ? init.body : undefined,
});
return new Response(
JSON.stringify({
name: "DATABASE_URL",
value: "postgres://...",
}),
{
status: 200,
headers: { "content-type": "application/json" },
}
);
}) as typeof fetch;

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.

🔍 Test mocks global fetch

The test replaces globalThis.fetch with a custom implementation. Repository guidance prohibits mocks and requires real test infrastructure.

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