Skip to content

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

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

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

Conversation

@Ishkirat-Singh

Copy link
Copy Markdown
Contributor

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

codecov-commenter commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11059   +/-   ##
=======================================
  Coverage        ?   60.91%           
=======================================
  Files           ?      651           
  Lines           ?    43805           
  Branches        ?     9011           
=======================================
  Hits            ?    26685           
  Misses          ?    14878           
  Partials        ?     2242           

☔ 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
Contributor 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
Contributor 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.

@ajperel

ajperel commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@Ishkirat-Singh - I just merged a significant change to parameter prompting for functions (#11086). It'd be good to update to latest and make sure this and #11062 play nicely with that change. But these seem like good fixes to land. Thank you for the contributions.

@Ishkirat-Singh

Copy link
Copy Markdown
Contributor Author

Thanks @ajperel — updated to latest, and I checked both against #11086.

Both fixes are still needed after your rewrite, and both still apply cleanly:

params.spec.ts passes on both branches (25 and 24 respectively, including the cases you added). Nothing else in either diff touches the code you changed.

@ajperel ajperel 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.

I agree this is a good change and just need to fix CHANGELOG

default: resolvedDefault as string,
// Choice values are stringified below, so the default must be too or a
// boolean/number default never matches and the first option is preselected.
default: resolvedDefault?.toString(),

@ajperel ajperel Sep 17, 2026 •

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.

I think at this point we could make a larger, better change where we don't stringify the values or defaults and get rid of the converters. But I'm not 100% confident without trying it and this smaller change does work, fixes a bug, and I appreciate the contribution.

Comment thread CHANGELOG.md Outdated
@IzaakGough
IzaakGough enabled auto-merge (squash) September 24, 2026 15:35

This branch has not been deployed

No deployments
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

5 participants