Skip to content

Adds support for optional params#10589

Open
Berlioz wants to merge 1 commit into
mainfrom
vsfan_opt_param
Open

Adds support for optional params#10589
Berlioz wants to merge 1 commit into
mainfrom
vsfan_opt_param

Conversation

@Berlioz
Copy link
Copy Markdown
Contributor

@Berlioz Berlioz commented Jun 2, 2026

Params with optional = true are only prompted for on a "fresh" functions deploy, where the corresponding .env file is empty.

Otherwise, they are automatically filled in with the param's default value, or a zero value based on the param's type. This can bypass validation for param types that support validation regexes.

Optional params resolved this way are not written to .env. (Optional params resolved by prompting on a fresh deploy are).

While we're here, remove the immutable param configuration, which is a holdover from cargo culting Extensions params and doesn't really have any meaning in the functions world. Immutability wasn't implemented and it wasn't present in the wire format for a param from the SDK so that config flag was just totally marooned from the outside universe.

@Berlioz Berlioz requested a review from ajperel June 2, 2026 23:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for optional parameters during Cloud Functions deployment. When a .env file is present, optional parameters are resolved to their default or type-specific zero value and marked as internal to prevent them from being written to .env. However, a critical bug was identified in resolveParams where the resolved value for an optional parameter is immediately overwritten by the subsequent promptParam call. A continue statement must be added inside the conditional block to prevent prompting for these optional parameters.

Comment on lines +431 to 434
if (promptable.optional && dotEnvPresent) {
paramValues[param.name] = defaultOrZeroValue(param, paramDefault);
}
paramValues[param.name] = await promptParam(param, firebaseConfig.projectId, paramDefault);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The value resolved for an optional parameter when a .env file is present is immediately overwritten by the subsequent promptParam call. You should add a continue statement inside the if block to skip prompting for optional parameters.

    if (promptable.optional && dotEnvPresent) {
      paramValues[param.name] = defaultOrZeroValue(param, paramDefault);
      continue;
    }
    paramValues[param.name] = await promptParam(param, firebaseConfig.projectId, paramDefault);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants