Skip to content

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Aug 26, 2025

Refactors resolveBackend to be a pure function by removing filesystem calls to write the resolved parameter values.

This separation is useful later on as we add support for things like remote source or deploying extensions through the CLI.

  • Made resolveBackend pure - no longer writes to filesystem
  • Added writeResolvedParams helper in src/functions/env.ts for param persistence
  • Updated all callsites to handle writing separately
  • Fixed malformed import paths (extra dots)
  • Added unit tests for new helper

No user-visible changes. New params are still written to .env.local (emulator) or .env.<projectId> (deployment).

This change refactors resolveBackend to be a pure function that no longer
writes to the filesystem. This separation of concerns improves testability
and prepares for remote source support where dotenv files may be optional.

Key changes:
- Remove filesystem writes from resolveBackend
- Add writeResolvedEnvsToFile helper in src/functions/env.ts
- Update all callsites to handle persistence separately
- Add comprehensive unit tests for the new helper
- Fix malformed import paths (extra dots)

The behavior remains unchanged - new non-internal params are still written
to .env files (.env.local for emulator, .env.<projectId> for deployment).
Copy link
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 @taeold, 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 refactors the resolveBackend function to eliminate its filesystem side-effects, making it a pure function. This change is a foundational step towards supporting remote Git sources and improves separation of concerns and testability without introducing user-visible behavior changes.

Highlights

  • Pure resolveBackend: The resolveBackend function no longer performs filesystem writes, returning resolved environment variables instead.
  • New Helper for Persistence: A new utility function, writeResolvedEnvsToFile, has been introduced in src/functions/env.ts to handle the persistence of resolved environment variables to .env files.
  • Updated Call Sites: All existing calls to resolveBackend have been updated to explicitly call the new writeResolvedEnvsToFile helper to maintain the previous behavior of writing environment variables.
  • Import Path Corrections: Several malformed import paths (e.g., ../../../api) have been corrected across the codebase.
  • New Unit Tests: Comprehensive unit tests have been added for the newly introduced writeResolvedEnvsToFile helper to ensure its correctness.
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

  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
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 is a well-executed refactoring that makes resolveBackend a pure function by moving filesystem side-effects to a new writeResolvedEnvsToFile helper. The changes are clean, logical, and well-tested. I have a couple of suggestions to further improve the code quality and maintainability of the new helper function.

taeold added 2 commits August 26, 2025 11:14
- Use proper ParamValue type instead of structural type for better type safety
- Remove redundant empty check (writeUserEnvs already handles this)
- Rename function from writeResolvedEnvsToFile to writeResolvedParams for clarity
- Update tests to use actual ParamValue instances
@taeold taeold requested a review from inlined August 26, 2025 19:00
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.

1 participant