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

Aberta
#4,264 2 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@hastyy já está trabalhando nisso.

Desde 9/10/2026.

  • #4291 de @ANSHSINGH050404 — fechado sem integrar
  • #4431 de @karandhaodiyal28-hash — fechado sem integrar
  • #4903 de @claxman — fechado sem integrar
  • #4925 de @Tyagiquamar — fechado sem integrar
  • #4968 de @kaiizer777 — fechado sem integrar

Avaliação

Dificuldade
1/5
Tempo estimado
Menos de uma hora
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
node.js, typescript
Domínio
api

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
16.5k
Forks
1.5k
Merge médio
1d 15h
PRs com merge (30d)
17

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de triggerdotdev/trigger.dev

Todas as issues de triggerdotdev/trigger.dev

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.