Skip to content

Initial refactor for moving secret logic to index.ts#10010

Merged
christhompsongoogle merged 8 commits into
mainfrom
genkitRefactor
Mar 4, 2026
Merged

Initial refactor for moving secret logic to index.ts#10010
christhompsongoogle merged 8 commits into
mainfrom
genkitRefactor

Conversation

@christhompsongoogle
Copy link
Copy Markdown
Contributor

Initial refactor for moving secret logic to index.ts

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improving the modularity and maintainability of the secret management functionality. By centralizing the apphosting:secrets:set command's logic into a dedicated action function, it becomes easier to manage and potentially reuse this complex workflow. The simplification of the selectBackendServiceAccounts function's interface also contributes to cleaner code and better type safety.

Highlights

  • Refactored Secret Setting Logic: The core logic for the apphosting:secrets:set command has been extracted from src/commands/apphosting-secrets-set.ts into a new, reusable function apphostingSecretsSetAction located in src/apphosting/secrets/index.ts.
  • Simplified Dialog Interface: The selectBackendServiceAccounts function in src/apphosting/secrets/dialogs.ts now directly accepts a nonInteractive boolean parameter instead of a generic options object, simplifying its usage.
  • Updated Test Cases: Corresponding test cases in src/apphosting/secrets/dialogs.spec.ts were updated to reflect the change in the selectBackendServiceAccounts function signature.

🧠 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.

Changelog
  • src/apphosting/secrets/dialogs.spec.ts
    • Updated calls to selectBackendServiceAccounts to pass false for the nonInteractive parameter instead of an empty object.
  • src/apphosting/secrets/dialogs.ts
    • Modified the selectBackendServiceAccounts function signature to accept a nonInteractive: boolean parameter instead of options: any.
    • Updated internal usage of the nonInteractive flag within the prompt.confirm calls.
  • src/apphosting/secrets/index.ts
    • Added new imports for colorette, dialogs, config, and getProject.
    • Introduced apphostingSecretsSetAction function to encapsulate the entire secret setting workflow, including secret creation, versioning, prompting for usage type (production/local), granting email access, and selecting backend service accounts.
  • src/commands/apphosting-secrets-set.ts
    • Removed various imports (clc, secrets, dialogs, config, utils, prompt) that are no longer needed in this file.
    • Refactored the command's action to delegate its execution to the newly created apphostingSecretsSetAction function, passing all necessary parameters.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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
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 refactors the logic for the apphosting:secrets:set command by moving it from the command definition file into a reusable action function in src/apphosting/secrets/index.ts. This is a good change that improves code organization and testability. The signature of selectBackendServiceAccounts was also improved to be more type-safe, removing an any type. I've found a couple of issues related to handling non-interactive mode in the new action function, which could cause the command to hang or fail when run in a CI/CD environment. My suggestions address these issues.

Comment on lines +315 to +321
const type = await prompt.select({
message: "Is this secret for production or only local testing?",
choices: [
{ name: "Production", value: "production" },
{ name: "Local testing only", value: "local" },
],
});
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.

high

This prompt.select call does not handle non-interactive mode. If this command is run with a --non-interactive flag (for example, in a CI environment), it will throw an error because there is no default value provided. You should pass the nonInteractive flag and provide a sensible default.

  const type = await prompt.select({
    message: "Is this secret for production or only local testing?",
    choices: [
      { name: "Production", value: "production" },
      { name: "Local testing only", value: "local" },
    ],
    nonInteractive: !!nonInteractive,
    default: "production",
  });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed

Comment on lines +324 to +327
const emailList = await prompt.input({
message:
"Please enter a comma separated list of user or groups who should have access to this secret:",
});
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.

high

Similar to the previous prompt, this prompt.input call does not handle non-interactive mode and will cause an error. You should pass the nonInteractive flag and provide a default value.

    const emailList = await prompt.input({
      message:
        "Please enter a comma separated list of user or groups who should have access to this secret:",
      nonInteractive: !!nonInteractive,
      default: "",
    });

@christhompsongoogle christhompsongoogle marked this pull request as ready for review March 3, 2026 20:14
Copy link
Copy Markdown
Member

@joehan joehan left a comment

Choose a reason for hiding this comment

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

This change looks good to me, tho it seems like there are some existing issues that you could fix in the drive-by if you want

@christhompsongoogle christhompsongoogle enabled auto-merge (squash) March 4, 2026 19:38
@christhompsongoogle christhompsongoogle merged commit 38d7303 into main Mar 4, 2026
57 of 60 checks passed
@christhompsongoogle christhompsongoogle deleted the genkitRefactor branch March 4, 2026 19:56
@falahat
Copy link
Copy Markdown
Contributor

falahat commented Mar 4, 2026

LGTM, we discussed non-interactive mode offline and agreed about the defaults for prod vs local

Copy link
Copy Markdown
Contributor

@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.

Approved

andrewbrook pushed a commit that referenced this pull request Mar 25, 2026
Initial refactor for moving secret logic to index.ts (#10010)
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