Skip to content

fix(functions): honor non-string defaults in params select prompts - #11059

Open
Ishkirat-Singh wants to merge 4 commits into
firebase:mainfrom
Ishkirat-Singh:fix/functions-params-select-default
Open

fix(functions): honor non-string defaults in params select prompts#11059
Ishkirat-Singh wants to merge 4 commits into
firebase:mainfrom
Ishkirat-Singh:fix/functions-params-select-default

Conversation

@Ishkirat-Singh

Copy link
Copy Markdown

Description

promptSelect stringifies every choice value (option.value.toString()) but passed the resolved default to the select prompt unchanged. A boolean or integer default therefore never matched a choice, and inquirer fell back to preselecting the first option. In non-interactive mode the same raw default was handed straight to the converter, where isTruthyInput calls .toLowerCase() on it.

This stringifies the default the same way the choices are, so defineBoolean/defineInt params with a select input preselect their declared default. promptSelectMultiple was checked as well: its values are already strings (T extends string), so it is not affected by this particular mismatch.

Fixes #11053

Scenarios Tested

  • Added unit tests in src/deploy/functions/params.spec.ts covering a boolean select default (false) and an int select default (2), asserting the default passed to the prompt and the resolved ParamValue.
  • npx mocha src/deploy/functions/params.spec.ts: 20 passing. Both new tests fail against main without the fix.

Sample Commands

N/A — the change is in the interactive firebase deploy --only functions param prompt.

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

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.

Code Review

This pull request fixes an issue where boolean and integer defaults in select prompts for function parameters were not honored, resulting in the first option being preselected. This is resolved by stringifying the resolvedDefault value in promptSelect so it matches the stringified choice values. Additionally, unit tests have been added to verify this behavior for both boolean and integer defaults, and the changelog has been updated. I have no feedback to provide.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@ad45804). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11059   +/-   ##
=======================================
  Coverage        ?   60.14%           
=======================================
  Files           ?      650           
  Lines           ?    43448           
  Branches        ?     8937           
=======================================
  Hits            ?    26131           
  Misses          ?    15140           
  Partials        ?     2177           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@IzaakGough IzaakGough left a comment

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.

Lgtm! Nice fix. Just needs a conflict in the changelog resolving

@Ishkirat-Singh
Ishkirat-Singh force-pushed the fix/functions-params-select-default branch from def40a4 to 10239c9 Compare September 10, 2026 19:47
@Ishkirat-Singh

Copy link
Copy Markdown
Author

Thanks! Rebased onto main and resolved the CHANGELOG conflict (the release reset the file), and updated the tests for the new resolveParams options object. Should be good to merge.

promptSelect stringifies every choice value but passed the resolved default
through unchanged, so a boolean or integer default never matched a choice and
inquirer fell back to the first option. Stringify the default the same way.

Fixes firebase#11053
@Ishkirat-Singh
Ishkirat-Singh force-pushed the fix/functions-params-select-default branch from 10239c9 to 008ee62 Compare September 10, 2026 23:09
@Ishkirat-Singh

Copy link
Copy Markdown
Author

@IzaakGough rebased onto main again (it had fallen behind by two commits), no conflicts this time. Ready to merge whenever you get a moment.

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.

functions params: select prompt ignores a non-string default and preselects the first option

4 participants