Skip to content

Improve error handling for App Hosting compute service account#8815

Merged
blidd-google merged 5 commits intomasterfrom
bl-fah-compute-sa-fixes
Jul 10, 2025
Merged

Improve error handling for App Hosting compute service account#8815
blidd-google merged 5 commits intomasterfrom
bl-fah-compute-sa-fixes

Conversation

@blidd-google
Copy link
Copy Markdown
Contributor

Follow-up to #8785. Improves error handling and messaging and adds a unit test to make sure the CLI throws if it encounters an unexpected error while trying to create the compute service account.

Copy link
Copy Markdown
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.

Summary of Changes

Hello @blidd-google, 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 focuses on enhancing the robustness and user experience around the App Hosting compute service account creation process. It refines error handling logic to ensure unexpected issues are properly propagated, improves user-facing messages for provisioning states, and adds a dedicated unit test to validate these error handling improvements.

Highlights

  • Improved Error Handling: The core logic for ensuring the App Hosting compute service account (ensureAppHostingComputeServiceAccount) has been refined to better distinguish between expected (e.g., 403 for permission issues, 404 for not found) and unexpected errors, ensuring that unexpected errors are properly re-thrown and not silently swallowed.
  • Enhanced User Messaging: The warning message displayed when the App Hosting compute service account is still provisioning (HTTP 400 status) has been updated to provide clearer guidance to the user, suggesting they try again if an error occurs.
  • New Unit Test: A new unit test has been added to backend.spec.ts specifically to verify that the CLI correctly throws an error when an unexpected status (e.g., 500) is encountered during the service account permission checks.
  • Refactored Error Flow: The prepare.ts file has been simplified by removing a redundant try-catch block around the ensureAppHostingComputeServiceAccount call. This centralizes the error handling for service account provisioning within backend.ts, making the overall flow cleaner and more maintainable.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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
Copy Markdown
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 enhances error handling for the App Hosting compute service account by refactoring error logic, improving a warning message, adding a unit test, and centralizing error handling. The changes improve code robustness and clarity.

Comment on lines +272 to +273
} else if (getErrStatus(err) !== 404) {
throw err;
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.

medium

Throwing the error directly might obscure the original error's context. Consider logging the error or including it as an original property in a new FirebaseError object to preserve the stack trace and debugging information.

    } else {
      // Log the unexpected error for debugging purposes.
      console.error("Unexpected error:", err);
      // Re-throw the error, possibly wrapping it in a FirebaseError to add context.
      throw new FirebaseError("Unexpected error during service account check", { original: err });
    }
@blidd-google blidd-google enabled auto-merge (squash) July 10, 2025 19:39
@blidd-google blidd-google merged commit 5d5a1bf into master Jul 10, 2025
49 of 50 checks passed
@blidd-google blidd-google deleted the bl-fah-compute-sa-fixes branch July 10, 2025 19:50
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants