Improve error handling for App Hosting compute service account#8815
Improve error handling for App Hosting compute service account#8815blidd-google merged 5 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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.tsspecifically 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.tsfile has been simplified by removing a redundanttry-catchblock around theensureAppHostingComputeServiceAccountcall. This centralizes the error handling for service account provisioning withinbackend.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
-
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. ↩
There was a problem hiding this comment.
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.
src/apphosting/backend.ts
Outdated
| } else if (getErrStatus(err) !== 404) { | ||
| throw err; |
There was a problem hiding this comment.
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 });
}
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.