-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix misleading typing for options.json. #9275
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
Fix misleading typing for options.json. #9275
Conversation
Created using spr 1.3.6-beta.1
Summary of ChangesHello @yuchenshi, 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 resolves a long-standing inconsistency in the Highlights
Using Gemini Code AssistThe 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
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 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
|
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 is an excellent pull request that addresses a long-standing issue with the misleading options.json
typing. The changes are thorough and systematically remove the incorrect usage pattern across the codebase, replacing it with the intended framework-level handling of JSON output. The update to options.ts
to explicitly type json
as undefined
and include a detailed comment explaining the correct approach is a fantastic improvement for future maintainability. The removal of dead and buggy code branches in various command files simplifies the logic and improves correctness. Overall, this is a high-quality cleanup and refactoring effort.
projectNumber: "", | ||
projectRoot: "", | ||
account: "", | ||
json: true, |
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.
The VSCE right now doesn't call Firestore commands. So I believe this should be a noop.
const backups: Backup[] = listBackupsResponse.backups || []; | ||
|
||
if (options.json) { | ||
logger.info(JSON.stringify(listBackupsResponse, undefined, 2)); |
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.
This branch isn't consistent with the return backups
. I believe the intention was to print listBackupsResponse
when --json
is used. But fulfilling that intention will cause a breaking change. So I kept it WAI (working as implemented) and left a TODO instead
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.
That was indeed the intention. It's possible that I didn't notice this when this was implemented the first time... sorry.
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.
No problem. The next major (breaking) release of the CLI should be coming up soon and feel free to make it return listBackupsResponse
by then
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.
This looks good to me once you remove the now unused logger imports that are making the linter mad.
|
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
* Remove overrides that diverge the test configuration from the build configuration. (#9300) Co-authored-by: Jamie Rothfeder <[email protected]> * Fix misleading typing for options.json. (#9275) * feat(dataconnect): Add confirmation for Gemini schema generation (#9282) * feat(dataconnect): add confirmation for Gemini schema generation Instead of directly asking for an app description to generate a schema with Gemini, this change first asks the user to confirm if they want to use Gemini. If the user confirms, it then prompts for the app description with a default value of "an app for ${setup.projectId}". * prompts * changelog * m * feedback * typo * metrics * Update index.ts --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --------- Co-authored-by: Jamie Rothfeder <[email protected]> Co-authored-by: Jamie Rothfeder <[email protected]> Co-authored-by: Yuchen Shi <[email protected]> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Description
options.json
has always been unset since at least 5 years ago but the typingin
options.ts
says that it exists. This led to two kinds of mistakes.if (options.json)
in command handlers. This effectively creates adead branch. I've tried my best to remove those -- should be noop.
json: false
when Options are required. It's a not anoop strictly-speaking but the tests should still pass since it is not
actually accessed in commands. (These are mostly found in tests.)
Alternatives considered: Setting
options.json
for real seems appealing butbranching on
options.json
is almost always a mistake. Unless in some obscureuse cases (not found in the code base), it is best to let the global handling
deal with
--json
the flag.Things taken care of by global handling:
firebase-tools/src/command.ts
Lines 315 to 319 in a952fb4
firebase-tools/src/command.ts
Line 211 in a952fb4
Note that the last step wraps the return value in a wrapper object:
{status: "success", result: ...}
. The dead branches I've removed allfailed to account for this. So if we had made
options.json
a real boolean,it'd cause quite a few breaking changes unless we fix those one by one.
Scenarios Tested
Existing unit tests. I've also logged
options.json
in commands and made sureit is always unset regardless of flags.
Sample Commands
N/A