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

Đang mở
#4,264 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hastyy đang làm issue này rồi.

Từ ngày 9/10/2026.

  • #4291 của @ANSHSINGH050404 — đã đóng, không merge
  • #4431 của @karandhaodiyal28-hash — đã đóng, không merge
  • #4903 của @claxman — đã đóng, không merge
  • #4925 của @Tyagiquamar — đã đóng, không merge
  • #4968 của @kaiizer777 — đã đóng, không merge

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
16.5k
Fork
1.5k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của triggerdotdev/trigger.dev

Tất cả issue của triggerdotdev/trigger.dev

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.