Functions params: a param with a default still fails deploy in --non-interactive mode

Abierto Apto para principiantes
#11,523 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@yeegz ya está trabajando en esto.

Desde el 18/11/2026.

  • #11546 de @yeegz — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nodejs, typescript
Área
cli

Línea de trabajo

Empieza en src/deploy/functions/params.ts alrededor de resolveParams (líneas 427-454), donde los parámetros que faltan en los archivos dotenv se añaden a la lista de prompts y el modo no interactivo lanza una excepción. Lee el manejo de valores predeterminados de ParamBase justo encima, luego revisa la cobertura existente en src/deploy/functions/params.spec.ts. Hecho significa que un deploy no interactivo resuelve valores predeterminados CEL literales o ya resolubles y solo da error para parámetros que siguen sin un valor, con una prueba que ejercite el caso del valor predeterminado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

api: functions type: bug
[REQUIRED] Environment info

firebase-tools: 15.35.0 (the same code is still on main at bd1d9f9)

Platform: Windows 11, Node.js 22, firebase-functions 7.4.0

[REQUIRED] Test case

A 2nd gen function with a string param that has a default, and no .env file in the functions folder:

import { defineString } from 'firebase-functions/params';
import { onRequest } from 'firebase-functions/https';

const greeting = defineString('GREETING', { default: 'hello' });

export const hi = onRequest((req, res) => {
  res.send(greeting.value());
});
[REQUIRED] Steps to reproduce
firebase deploy --only functions --non-interactive
[REQUIRED] Expected behavior

The deploy uses the param's default (GREETING=hello). The docs (https://firebase.google.com/docs/functions/config-env) say the CLI prompts for a param during deployment "if they are not present in those files and no default is set", so a param with a default shouldn't need a prompt, and therefore shouldn't fail when the CLI can't prompt. The ParamBase type in params.ts says the same: "Default value. If not provided, a param must be supplied."

[REQUIRED] Actual behavior
Error: In non-interactive mode but have no value for the following environment variables: GREETING
To continue, either run `firebase deploy` with an interactive terminal, or add values to a dotenv file.

In interactive mode the CLI still prompts for it, with the default prefilled.

resolveParams sends every param that is not in a dotenv file to the prompt list, regardless of default, and in non-interactive mode throws if that list isn't empty:
https://github.com/firebase/firebase-tools/blob/bd1d9f917594e3f9c2c4aa57fe0d2df71d6aaaa6/src/deploy/functions/params.ts#L427-L454

I hit this in a real project (param BUSINESS_TIME_ZONE with a default, deployed from a script); the workaround was adding the value to functions/.env.

Possible fix: in non-interactive mode, resolve params that have a default (literal, or a CEL expression that can already be resolved) to that default, and only throw for the ones left without a value. I'd be happy to send a PR with tests if that's the intended behavior.

Lenguaje dominante
TypeScript
Estrellas
4.5k
Forks
1.3k
Merge medio
3 d 9 h
PR fusionados (30 d)
99

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de firebase/firebase-tools

Todos los issues de firebase/firebase-tools

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.