bug: envvars.update() throws "ReferenceError: name is not defined" outside a task context

未關閉
#4,264 2 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@hastyy 已經在處理了。

開始於 2026年10月9日。

  • #4291 來自 @ANSHSINGH050404 —— 已關閉,未合併
  • #4431 來自 @karandhaodiyal28-hash —— 已關閉,未合併
  • #4903 來自 @claxman —— 已關閉,未合併
  • #4925 來自 @Tyagiquamar —— 已關閉,未合併
  • #4968 來自 @kaiizer777 —— 已關閉,未合併

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
node.js, typescript
領域
api

研究方向

Start in src/v3/envvars.ts at update() and compare the non-task-context argument resolution with the working del, retrieve, and create methods. Check for an existing regression test for calling update() outside a task context; done means that call no longer throws and the env var update succeeds.

由索引模型根據 Issue 內容生成。

描述

Env Info

  System:
    OS: macOS 26.5.2
    CPU: (15) arm64 Apple M5 Pro
    Memory: 2.33 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.7.0 - /Users/patrick/.nvm/versions/node/v24.7.0/bin/node
    npm: 11.5.1 - /Users/patrick/.nvm/versions/node/v24.7.0/bin/npm
    pnpm: 11.1.1 - /opt/homebrew/bin/pnpm

Description

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 task
await envvars.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.js update() non-task branch:

$projectRef = projectRefOrName;
$slug = slugOrParams;
$name = name;      // <- undefined reference
$params = params;

Suggested fix

$name = nameOrRequestOptions;

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

主要語言
TypeScript
星號
16.5k
分支
1.5k
平均合併
1 天 15 小時
30 天內合併 PR
17

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

triggerdotdev/trigger.dev 的其他 Issue

查看 triggerdotdev/trigger.dev 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。