fix(sdk): resolve ReferenceError and projectRef in envvars.update (#4264) - #4968
kaiizer777 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 85a28b1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
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 |
|
Vouch request is open at #4963. Ready for review once vouched! |
|
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. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Resolves #4264
Root Cause
In
packages/trigger-sdk/src/v3/envvars.ts, the implementation function parameter is namednameOrRequestOptions, but the out-of-task execution branch at line 341 assigned$name = name!;. Becausenamewas not in scope, runningenvvars.update(projectRef, slug, name, params)from Node outside of a task context threwReferenceError: name is not defined.Additionally, in the in-task 4-argument branch (
update(projectRef, slug, name, params)),$projectRefwas assigned fromslugOrParamsinstead ofprojectRefOrName, 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
packages/trigger-sdk/src/v3/envvars.ts:$name = nameOrRequestOptions;in the out-of-task branch, resolving theReferenceError.typeof nameOrRequestOptions === "string"in both task and non-task 4-argument branches, throwing"name is required"if missing.$projectRef = projectRefOrName;in the in-task 4-argument branch to ensure the correct project reference is used in the API request path.packages/trigger-sdk/src/v3/envvars.test.tstesting:slug,name, orparamsare missing.project.refandenvironment.slugfrom context, 4-argument update preserving explicitprojectRef,slug, andname, and validation for missingnameandparams.@trigger.dev/sdk.Note
A vouch request for CI/contributions is open at #4963.