-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[VS Code] Fix the no project emulator experience #9072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 @fredzqm, 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 significantly enhances the robustness and clarity of error handling within the VS Code extension's Data Connect integration. By introducing explicit error throwing for unresolved configurations and refining how API service paths are generated, the changes aim to provide more immediate and informative feedback when expected Data Connect configurations are missing or improperly referenced.
Highlights
- Improved error handling for serviceId resolution: Methods like findById and findEnclosingServiceForPath now throw specific errors when a Data Connect configuration is not found, providing clearer diagnostics.
- Enhanced robustness in API service path generation: The getApiServicePathByPath method now gracefully handles an undefined projectId by providing a default placeholder, preventing potential runtime issues.
- Refactored servicePath logic: The servicePath method in service.ts has been streamlined to rely on the improved error handling from config.ts, reducing redundant checks and making the code more concise.
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 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
-
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.
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 improves error handling when resolving a service ID by throwing errors instead of returning undefined
. This makes the code more robust and error paths more explicit. The changes are well-contained within ResolvedDataConnectConfigs
and DataConnectService
. My review includes suggestions to further enhance code clarity and type safety by removing redundant optional chaining and updating function signatures to align with the new error handling strategy.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to agree on a single default project name. I'd say demo-local
or something explicit like demo-no-project
.
Right now, different values are used in different places, such as ""
, "p"
and "local-demo"
. The last one may even conflict with a real project with that name. (demo-*
is reserved but local-*
is not)
What's your recommendation? I don't mind any of them. Just want this to work BTW, project doesn't matter for FDC emulator. We key based on just service_id. |
What do you think? There is no project. The only thing that needs to be specified is the discovery file when project is missing.
Better? |
@fredzqm I recommend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just have this default to demo-no-project
SGTM. Just changed the PR to use |
const serviceId = dataConnectConfig?.value.serviceId; | ||
const locationId = dataConnectConfig?.dataConnectLocation; | ||
return `projects/${projectId}/locations/${locationId}/services/${serviceId}`; | ||
return `projects/${projectId || "p"}/locations/${locationId}/services/${serviceId}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this? If so, I'd suggest
return `projects/${projectId || "p"}/locations/${locationId}/services/${serviceId}`; | |
return `projects/${projectId || "demo-ignored"}/locations/${locationId}/services/${serviceId}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when .firebaserc
is missing. project
is undefined here.
Sure, I will use the no-project placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add a comment that the Data Connect emulator ignores the project ID and will return the right response pretending that there's only one project
src/emulator/controller.ts
Outdated
host: pubsubAddr.host, | ||
port: pubsubAddr.port, | ||
projectId, | ||
projectId: projectId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this
src/emulator/controller.ts
Outdated
} | ||
|
||
const hubClient = new EmulatorHubClient(projectId); | ||
const hubClient = new EmulatorHubClient(projectId || ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const hubClient = new EmulatorHubClient(projectId || ""); | |
const hubClient = new EmulatorHubClient(projectId); |
@joehan I think this PR still need a LGTM from you because there was a "requested change" before. |
@@ -1,0 +1 @@ | |||
- `firebase emulator:start` use a default project if no project can be found. (#9072) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `firebase emulator:start` use a default project if no project can be found. (#9072) | |
- Changed `firebase emulator:start` to use a default project `demo-no-project` if no project can be found. (#9072) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, my bad. Shouldn't have enable auto-merge.
Previously, if a project isn't available locally:
This PR addressed numerous edge cases to make sure the no project experience is smooth.
When project is missing,
/var/folders/6x/5fwhc57j2b10smkj7m5fgsjw00k66j/T/hub-local-demo.json
). This allows VS Code to discover the projectless emulator easily.Tested: https://screencast.googleplex.com/cast/NjAyMjU3NjcyNjg2Nzk2OHxiNzU5MDVjNC1hMA