fix(sdk): use nameOrRequestOptions in envvars.update outside a task - #4903
fix(sdk): use nameOrRequestOptions in envvars.update outside a task#4903claxman wants to merge 1 commit into
Conversation
The 4-arg management form assigned $name from a binding that is not a
parameter. TypeScript accepted it via the DOM global. Node throws
ReferenceError before any request.
Repro: tsx --eval update("proj_x","dev","FOO",{value:"bar"}) on 0a23814.
Guard the string, assign nameOrRequestOptions, add envvars.test.ts.
Tests failed with ReferenceError without the assignment, 2 passed after.
🦋 Changeset detectedLatest commit: d8fcd9b 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 |
|
Hi @claxman, 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. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
WalkthroughThe SDK now validates the environment variable name in the non-context ✨ 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 |
Fixes #4264
envvars.update(projectRef, slug, name, params)from a plain Node script throwsReferenceError: name is not definedbefore any HTTP call. Repro on 0a23814:Cause: the implementation parameter is
nameOrRequestOptions, but the non-task branch assigned$namefrom a barenamebinding at envvars.ts:341. Typecheck passes becauselib.domdeclares a globalname. Node has none.Fix: the non-task branch checks
typeof nameOrRequestOptions === "string"(same shape as the slug/params checks next to it) and assigns that.Not touched: the in-task 4-arg branch. With
taskContextprojectproj_ctx/ envprod, the same call PUTshttp://x/api/v1/projects/dev/envvars/dev/FOObecause that branch sets$projectRef = slugOrParams. Separate bug, left for a follow-up.Test:
packages/trigger-sdk/src/v3/envvars.test.tsuses a local HTTP server likeauth.test.tsand asserts the PUT path/api/v1/projects/proj_x/envvars/dev/FOOand body{value:"bar"}. Without the assignment change both tests fail with the ReferenceError above. With it,pnpm run test ./src/v3/envvars.test.ts --runreports 2 passed.oxlintandoxfmt --checkon the two changed files are clean.