functions params: select prompt ignores a non-string default and preselects the first option
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli
Research direction
Start in src/deploy/functions/params.ts around promptSelect at lines 914-928, then inspect promptSelectMultiple around line 953 for the related list-default behavior. Reproduce the boolean select with MAKE_PUBLIC unset and verify that the declared default is matched after option values are converted; confirm the corresponding list behavior is also handled.
Written by the indexing model from the issue text.
Description
[REQUIRED] Environment info
firebase-tools: 15.26.0 (code is unchanged on main at ecda4df)
Platform: Windows (not platform specific)
[REQUIRED] Test case
A non-string param with a select input whose default is not the first option:
import { defineBoolean, select } from "firebase-functions/params";
export const makePublic = defineBoolean("MAKE_PUBLIC", {
label: "Make resized images public",
default: false,
input: select({ Yes: true, No: false }),
});
[REQUIRED] Steps to reproduce
- Declare the param above in a functions codebase.
- Run
firebase deploy --only functionswithMAKE_PUBLICunset so the CLI prompts for it. - Observe which option is highlighted, then press Enter.
[REQUIRED] Expected behavior
"No" is preselected, since the declared default is false. Pressing Enter stores MAKE_PUBLIC=false.
[REQUIRED] Actual behavior
"Yes" (the first option) is preselected. Pressing Enter stores MAKE_PUBLIC=true.
Cause: promptSelect passes the resolved default to inquirer unchanged but stringifies every option value, so a boolean or number default never matches a choice and inquirer falls back to the first one.
const response = await select<string>({
default: resolvedDefault as string,
...
choices: input.select.options.map((option) => ({
value: option.value.toString(),
Affects defineBoolean and defineInt selects; string selects are fine. Any param whose default is the first option looks correct by coincidence, which is why this is easy to miss.
Suggested fix: default: resolvedDefault?.toString() (or compare against option.value before stringifying). promptSelectMultiple (L953) has the same pattern for defineList defaults.
Found while migrating the storage-resize-images extension to a Function Kit: firebase/extensions#3148 works around it by declaring the param as a string.
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 73
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-tools
-
api: functions reproducible type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
firebase/firebase-tools#11066 · 2 comments ·
-
emulators: functions type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
firebase/firebase-tools#10398 ·
-
emulator-suite emulators: functions help-wanted type: feature request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
firebase/firebase-tools#3728 · 9 comments ·
-
emulator: dataconnect type: bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
firebase/firebase-tools#11127 ·
-
api: remoteconfig type: bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
firebase/firebase-tools#11125 ·
All issues in firebase/firebase-tools
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100