Skip to content

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

Open

Description

@rolandocesar-prog-dev

[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:

const [resolved, outstanding] = partition(params, (param) => {
return {}.hasOwnProperty.call(userEnvs, param.name);
});
for (const param of resolved) {
paramValues[param.name] = userEnvs[param.name];
}
const [needSecret, needPrompt] = partition(outstanding, (param) => param.type === "secret");
// The functions emulator will handle secrets
if (!isEmulator) {
for (const param of needSecret) {
secretRefs[param.name] = await ensureSecret(
param as SecretParam,
firebaseConfig.projectId,
nonInteractive,
);
}
}
if (nonInteractive && needPrompt.length > 0) {
const envNames = needPrompt.map((p) => p.name).join(", ");
throw new FirebaseError(
`In non-interactive mode but have no value for the following environment variables: ${envNames}\n` +
"To continue, either run `firebase deploy` with an interactive terminal, or add values to a dotenv file. " +
"For information regarding how to use dotenv files, see https://firebase.google.com/docs/functions/config-env",
);
}

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.

Activity

  1. IzaakGough commented on Nov 16, 2026

    @IzaakGough
    Contributor

    Hi @rolandocesar-prog-dev thanks for raising this! We will investigate as soon as possible.

  2. IzaakGough commented on Nov 17, 2026

    @IzaakGough
    Contributor

    Hi @rolandocesar-prog-dev I raised this one internally and this is the update:

    • In non-interactive mode the CLI should resolve to the default value if one exists. Happy to review a PR here if you'd like to pick this change up.

    • For interactive mode, the current behavior is intentional; that is, even if a param has a defined default, the CLI will still prompt for this param but will pre-fill with the default value. However the documentation here is not accurate and so these are in the process of being changed.

  3. yeegz commented on Nov 17, 2026

    @yeegz

    Hi! I've put together a fix for this along the lines you described: in non-interactive mode, params with a default resolve to it (same CEL and type checks as the prompt path), and only params with no default error. Tests are included. @rolandocesar-prog-dev, if you're not already working on it, mind if I open the PR?

  4. added 2 commits that reference this issue on Nov 18, 2026
    e1b3f6a
    eb4a19f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions