Skip to content

Add ability to set a runtime flag in the CLI#9726

Merged
falahat merged 21 commits intomainfrom
runtimes
Mar 19, 2026
Merged

Add ability to set a runtime flag in the CLI#9726
falahat merged 21 commits intomainfrom
runtimes

Conversation

@falahat
Copy link
Contributor

@falahat falahat commented Jan 12, 2026

Description

  • Adds fields for automatic base image updates, which also includes passing a runtime when creating a backend
  • Display ABIU-related fields for backends:list if the ABIU experiment is enabled

Scenarios Tested

See the full test plan below (I ran with Gemini and then re-ran it manually as a final pass.)

Sample Commands

See the full test plan in a below comment.

Prompt for runtime selection in interactive mode:

firebase apphosting:backends:create
# Expected Prompt:
# ? Which runtime do you want to use? (Use arrow keys)
# ❯ Node.js (default)
#   Node.js 22

Today, the list of valid runtimes is hardcoded but the CLI will be able to call the Control Plane API, ListSupportedRuntimes, to fetch the list live.

Create a backend with an empty runtime (defaults to nodejs runtime):

firebase apphosting:backends:create --backend my-backend --primary-region us-central1 --runtime "" --non-interactive
# Expected Result: Backend created with 'nodejs' runtime.

Create a backend with an unsupported runtime (expected to fail):

firebase apphosting:backends:create --runtime nodejs18
# Expected Error:
# Error: HTTP Error: 400, InvalidArgument: runtime "nodejs18" is not supported

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @falahat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Firebase CLI's apphosting:backends:create command by enabling users to explicitly define the runtime environment for their new App Hosting backends. It provides flexibility through a new command-line flag and an interactive selection process, while also ensuring a sensible default for non-interactive operations. The changes integrate this new capability into the backend creation logic and include corresponding unit tests.

Highlights

  • New CLI Option: Introduced a new --runtime option for the firebase apphosting:backends:create command, allowing users to specify the desired runtime (e.g., nodejs, nodejs22) when creating a backend.
  • Interactive Runtime Selection: When creating a backend interactively and no runtime is specified, the CLI will now prompt the user to select between available runtimes, such as 'Node.js (default)' and 'Node.js 22'.
  • Non-Interactive Default Runtime: For non-interactive backend creation, if the --runtime flag is not provided, the system will automatically default to the nodejs runtime.
  • Backend API Integration: The createBackend function and related API interfaces have been updated to accept and process the specified runtime, ensuring it is correctly passed to the App Hosting API.
  • Unit Test Coverage: New unit tests have been added to verify that the createBackend function correctly handles and passes both nodejs and nodejs22 runtimes to the underlying API.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 adds the ability to specify a runtime via a new --runtime flag in the CLI when creating an App Hosting backend. The implementation is straightforward and includes new unit tests to cover the changes. My review includes a couple of suggestions to improve code maintainability by reducing duplication in both the core logic and the tests.

@falahat
Copy link
Contributor Author

falahat commented Mar 13, 2026

I used gemini to run through some manual test flows. I'm going to verify these manually as well.

Manual Test Results


Scenario 1: Experiment Gating

1.1: Experiment Disabled

Command:

firebase experiments:disable abiu
firebase apphosting:backends:create --project PROJECT_ID --help

Result: ABIU-related flags (--runtime, --automatic-base-image-updates, --no-automatic-base-image-updates) are hidden from help output.

Command:

firebase apphosting:backends:create --project PROJECT_ID --runtime nodejs22

Result: Fails with Error: Unknown option --runtime. (VERIFIED)


Scenario 2: Creation Permutations

2.1: Explicitly Enable ABIU

Command:

firebase experiments:enable abiu
firebase apphosting:backends:create --project PROJECT_ID --automatic-base-image-updates --debug

Result: Backend created successfully. Status in list: N/A.

Note

"N/A" is expected in staging because the server omits the false field for automaticBaseImageUpdatesDisabled (Proto3 default), which the CLI interprets as N/A.

2.2: Runtime + Explicit ABIU

Command:

firebase apphosting:backends:create --project PROJECT_ID --runtime nodejs22 --automatic-base-image-updates --debug

Result: Backend created successfully. Status in list: N/A.

2.3: Implicit ABIU (Default)

Command:

firebase apphosting:backends:create --project PROJECT_ID --runtime nodejs22 --debug

Result: Backend created successfully. Status in list: N/A.

2.4: Explicitly Disable ABIU

Command:

firebase apphosting:backends:create --project PROJECT_ID --no-automatic-base-image-updates --debug

Result: Backend created successfully. Status in list: Disabled. (VERIFIED)

2.5: Runtime + Disable ABIU

Command:

firebase apphosting:backends:create --project PROJECT_ID --runtime nodejs22 --no-automatic-base-image-updates --debug

Result: Backend created successfully. Status in list: Disabled.

2.6: Empty Runtime Flag (The "Swallowing" Fix)

Command:

firebase apphosting:backends:create --project PROJECT_ID --runtime "" --debug

Result:

  • CLI correctly identifies that runtime is missing.
  • CLI prompts for runtime selection.
  • Subsequent flags (if any) would not be swallowed.
  • Backend created after interactive selection. (VERIFIED FIX)

Scenario 3: Non-Interactive Mode

3.1: Explicit All Flags

Command:

firebase apphosting:backends:create --project PROJECT_ID --backend non-int-explicit --primary-region us-central1 --runtime nodejs22 --no-automatic-base-image-updates --non-interactive --debug

Result: Backend created successfully with specified values. (VERIFIED)

3.2: Missing Required Flag (The "Defaulting" Behavior)

Command:

firebase apphosting:backends:create --project PROJECT_ID --backend non-int-missing --primary-region us-central1 --non-interactive --debug

Result:

  • Backend created successfully.
  • Discovery: CLI defaults runtime to nodejs when abiu experiment is enabled and no runtime is provided in non-interactive mode. (OBSERVED)

3.3: Explicit Empty Runtime Flag

Command:

firebase apphosting:backends:create --project PROJECT_ID --backend non-int-empty --primary-region us-central1 --runtime "" --non-interactive --debug

Result:

  • CLI correctly sends {"runtime":{"value":""}} to the API.
  • No interactive prompt is triggered (as expected in --non-interactive). (VERIFIED)

3.4: Experiment Gating (Non-Interactive)

Command:

firebase experiments:disable abiu
firebase apphosting:backends:create --project PROJECT_ID --backend non-int-gated --primary-region us-central1 --runtime nodejs22 --non-interactive --debug

Result: Correctly fails with error: unknown option '--runtime'. (VERIFIED)


Summary of Findings

Feature Status Notes
Experiment Gating ✅ PASSED Flags are correctly hidden/rejected when abiu experiment is off (Interactive & Non-Interactive).
Runtime Selection ✅ PASSED nodejs22 is accepted. Empty string "" in interactive mode now triggers a prompt.
ABIU Status Column ✅ PASSED "Disabled" shows correctly. "N/A" shows for Enabled (Status: known staging server behavior).
Non-Interactive Mode ✅ PASSED Correctly handles all flags. Defaults runtime to nodejs if missing but experiment is on.
No Flag Swallowing ✅ PASSED Fixed the issue where --runtime "" would swallow the next flag.

@falahat
Copy link
Contributor Author

falahat commented Mar 13, 2026

I manually confirmed these test cases. I found 2 issues:

  1. When we pass "" as runtime to the backend, the backend.runtime is saved as "". However, it should default to "nodejs". This actually will be safe because "" and "nodejs" will behave the same but we should clarify the behavior.

  2. We can't compute the "ABIU" column correctly for legacy (pre-ABIU) backends. The "ABIU" column in backends:list depends on the automatic_base_image_updates_disabled field. However, when this field is false, it's not sent in the JSON response. So we can't distinguish false from undefined. So if ABIU is enabled OR the backend was created before ABIU (and therefore isnt actually using ABIU), then the ABIU column in backends:list will treat these the same.

I don't think either of these issues are blockers for this pull request, however.

Copy link
Contributor Author

@falahat falahat left a comment

Choose a reason for hiding this comment

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

I need to also verify if the "init" command needs to be updated, since that also creates backends.

@falahat
Copy link
Contributor Author

falahat commented Mar 13, 2026

/gemini review

Copy link
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 adds the ability to specify a runtime and configure automatic base image updates when creating an App Hosting backend via the CLI. The changes are gated behind the abiu experiment flag. The implementation looks solid, with corresponding updates to the backend list command and comprehensive unit tests for the new functionality. I have one suggestion to improve the readability of the flag parsing logic.

Comment on lines +60 to +62
const automaticBaseImageUpdatesDisabled = abiuAllowed
? options.automaticBaseImageUpdates === false
: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for automaticBaseImageUpdatesDisabled is concise but relies on subtle behavior of how commander handles paired flags like --[no-]automatic-base-image-updates. To improve long-term maintainability and make the code more self-documenting, consider refactoring this to be more explicit.

    let automaticBaseImageUpdatesDisabled: boolean | undefined;
    if (abiuAllowed) {
      // When --no-automatic-base-image-updates is used, options.automaticBaseImageUpdates is false.
      // Otherwise, it's true or undefined. We default to enabling updates unless explicitly disabled.
      automaticBaseImageUpdatesDisabled = options.automaticBaseImageUpdates === false;
    }

@falahat falahat requested a review from annajowang March 17, 2026 20:55
@falahat falahat marked this pull request as ready for review March 17, 2026 20:56
@falahat falahat requested review from Yuangwang and removed request for annajowang March 17, 2026 21:37
@falahat
Copy link
Contributor Author

falahat commented Mar 18, 2026

/gemini review

Copy link
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 the ability to specify a runtime and control automatic base image updates (ABIU) for App Hosting backends, gated by an abiu experiment flag. The changes include updating API types, modifying the apphosting:backends:create command to accept new options, and dynamically adjusting the apphosting:backends:list output. New unit tests have been added to cover the new functionality and flag interactions.

There is a discrepancy between the expected behavior for an empty runtime string as described in the pull request's sample commands and the current implementation. The CLI should treat an empty string provided via --runtime "" as an implicit request for the default runtime, rather than passing an empty string to the API.

@falahat falahat enabled auto-merge (squash) March 18, 2026 23:02
@falahat falahat disabled auto-merge March 18, 2026 23:04
@falahat falahat enabled auto-merge (squash) March 18, 2026 23:06
auto-merge was automatically disabled March 19, 2026 00:00

Base branch requires signed commits

@falahat falahat enabled auto-merge (squash) March 19, 2026 00:01
@falahat falahat merged commit df732a7 into main Mar 19, 2026
68 of 73 checks passed
@falahat falahat deleted the runtimes branch March 19, 2026 00:24
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.

4 participants