-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(sdk): resolve ReferenceError in envvars.update outside task context #4291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ANSHSINGH050404
wants to merge
1
commit into
triggerdotdev:main
from
ANSHSINGH050404:fix/envvars-update-out-of-task-context
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@trigger.dev/sdk": patch | ||
| --- | ||
|
|
||
| Fix `envvars.update()` throwing `ReferenceError: name is not defined` when called outside a task run (for example from a deploy script). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 In-task 4-arg update form sends slug as projectRef
The PR fixes the out-of-task branch (
envvars.ts:335-346), which is now correct. However the in-task branch of the sameupdatefunction has a related pre-existing bug that this PR does not address. Whenupdate(projectRef, slug, name, params)(the 4-arg overload) is called from inside a task,taskContext.ctxis truthy andslugOrParamsis a string, so execution entersenvvars.ts:307-319. There$projectRef = slugOrParamsassigns the slug argument to the project ref (envvars.ts:308), and$slug = slugOrParams ?? taskContext.ctx.environment.slugalso resolves to the slug — so the realprojectRefOrName(the actual project ref) is dropped entirely and the wrong value is sent toupdateEnvVar. Compare withcreate/upload(envvars.ts:147-152) which correctly use$projectRef = projectRefOrParamsand derive$slugfromslugOrRequestOptions. Additionally the$namefallback atenvvars.ts:310-313falls back toenvironment.slugrather than throwing/using the name, which is also incorrect. This branch is reachable because the type overloads permit the 4-arg form regardless of task context. It is outside the changed diff hunk so it could not be reported as a bug, but a reviewer should decide whether to fix it in the same PR since it is in the exact function being patched.(Refers to lines 307-324)
Was this helpful? React with 👍 or 👎 to provide feedback.