fix(functions): honor non-string defaults in params select prompts - #11059
fix(functions): honor non-string defaults in params select prompts#11059Ishkirat-Singh wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
IzaakGough
left a comment
There was a problem hiding this comment.
Lgtm! Nice fix. Just needs a conflict in the changelog resolving
def40a4 to
10239c9
Compare
|
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
10239c9 to
008ee62
Compare
|
@IzaakGough rebased onto main again (it had fallen behind by two commits), no conflicts this time. Ready to merge whenever you get a moment. |
Description
promptSelectstringifies every choice value (option.value.toString()) but passed the resolved default to theselectprompt 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, whereisTruthyInputcalls.toLowerCase()on it.This stringifies the default the same way the choices are, so
defineBoolean/defineIntparams with aselectinput preselect their declared default.promptSelectMultiplewas checked as well: its values are already strings (T extends string), so it is not affected by this particular mismatch.Fixes #11053
Scenarios Tested
src/deploy/functions/params.spec.tscovering a boolean select default (false) and an int select default (2), asserting thedefaultpassed to the prompt and the resolvedParamValue.npx mocha src/deploy/functions/params.spec.ts: 20 passing. Both new tests fail againstmainwithout the fix.Sample Commands
N/A — the change is in the interactive
firebase deploy --only functionsparam prompt.