You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: envvars.update() throws "ReferenceError: name is not defined" outside a task context #4264
Calling envvars.update(projectRef, slug, name, params) from outside a task run (a plain Node script / CI deploy step) always throws ReferenceError: name is not defined. envvars.create, del, retrieve, and list all work fine from the same context.
SDK version
@trigger.dev/sdk 4.5.0. The code path looks unchanged in the published dist, so 4.5.x is likely affected too — please confirm on the latest.
Reproduction
import{envvars}from"@trigger.dev/sdk";// TRIGGER_ACCESS_TOKEN set in env; NOT running inside a taskawaitenvvars.update("proj_xxx","staging","MY_VAR",{value: "hello"});
ReferenceError: name is not defined
at Module.update (@trigger.dev/sdk/src/v3/envvars.ts:343:5)
Root cause
update(projectRefOrName, slugOrParams, nameOrRequestOptions, params, requestOptions) — the non-task-context branch resolves the name as:
$name=name;// ❌ there is no `name` parameter here; the positional param is `nameOrRequestOptions`
Unlike del/retrieve (whose third positional parameter is literally named name), update's third parameter is nameOrRequestOptions, so name is not in scope and the call throws. The in-task-context branch is correct.
For reference, the compiled dist/commonjs/v3/envvars.jsupdate() non-task branch:
(matching how $projectRef / $slug / $params are resolved from the positional args in the same branch).
Impact / workaround
envvars.update() is unusable from the management-API path (e.g. updating an env var from a deploy script). Workaround: envvars.del() followed by envvars.create(). create, del, retrieve, and list are unaffected.
changed the title [-]envvars.update() throws "ReferenceError: name is not defined" outside a task context[/-][+]bug: envvars.update() throws "ReferenceError: name is not defined" outside a task context[/+]on Jul 15, 2026
Confirming on the latest as asked — still broken on @trigger.dev/sdk@4.5.13:
ERROR: ReferenceError: name is not defined
create() from the same script reaches the network layer (AuthenticationError: Invalid API key with a dummy token), so the failure is specific to update() and happens before any request is made.
The line is in the non-task branch of update() in the published dist/commonjs/v3/envvars.js:
functionupdate(projectRefOrName,slugOrParams,nameOrRequestOptions,params,requestOptions){
...
}else{$projectRef=projectRefOrName;$slug=slugOrParams;$name=name;// <- no `name` parameter exists$params=params;}
The third parameter is nameOrRequestOptions, so name resolves to nothing and throws. It should be:
$name=nameOrRequestOptions;
typeof nameOrRequestOptions === "string" is probably worth asserting there too, since that branch has already established the 4-arg form.
Why only this path: the other methods never reference a bare name, and inside a task run the taskContext.ctx branch is taken instead, which assigns $name from real parameters. So it only surfaces outside a task, which matches the report exactly. (In a browser this would silently pick up window.name rather than throwing — Node has no such global, which is why it's a hard error here.)
One other thing worth a look while that function is open — the first task-context branch assigns both from the same argument:
$projectRef taking slugOrParams looks unintended given the parameter names, though I haven't exercised that path so I can't say what the intended behaviour is.
Ran tsx --eval with update("proj_x","dev","FOO",{value:"bar"}) against packages/trigger-sdk/src/v3/envvars.ts on 0a23814. It threw ReferenceError: name is not defined at line 341 ($name = name!) before any request. Taking this.
Activity
[-]envvars.update() throws "ReferenceError: name is not defined" outside a task context[/-][+]bug: envvars.update() throws "ReferenceError: name is not defined" outside a task context[/+]itzzdev09 commentedon Aug 28, 2026
Confirming on the latest as asked — still broken on
@trigger.dev/sdk@4.5.13:create()from the same script reaches the network layer (AuthenticationError: Invalid API keywith a dummy token), so the failure is specific toupdate()and happens before any request is made.The line is in the non-task branch of
update()in the publisheddist/commonjs/v3/envvars.js:The third parameter is
nameOrRequestOptions, sonameresolves to nothing and throws. It should be:typeof nameOrRequestOptions === "string"is probably worth asserting there too, since that branch has already established the 4-arg form.Why only this path: the other methods never reference a bare
name, and inside a task run thetaskContext.ctxbranch is taken instead, which assigns$namefrom real parameters. So it only surfaces outside a task, which matches the report exactly. (In a browser this would silently pick upwindow.namerather than throwing — Node has no such global, which is why it's a hard error here.)One other thing worth a look while that function is open — the first task-context branch assigns both from the same argument:
$projectReftakingslugOrParamslooks unintended given the parameter names, though I haven't exercised that path so I can't say what the intended behaviour is.claxman commentedon Sep 7, 2026
Ran
tsx --evalwithupdate("proj_x","dev","FOO",{value:"bar"})againstpackages/trigger-sdk/src/v3/envvars.tson 0a23814. It threwReferenceError: name is not definedat line 341 ($name = name!) before any request. Taking this.