Skip to content

feat: Add validation for function prefixes and source/prefix pairs #8911

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Jul 30, 2025

This change introduces two new validation rules for function configurations in firebase.json:

  1. The prefix property, if specified, must only contain lowercase letters, numbers, and hyphens.
  2. The combination of source and prefix must be unique across all function configurations.

These changes ensure that function deployments with prefixes are valid and that there are no conflicts when deploying multiple functions from the same source directory.

google-labs-jules bot and others added 2 commits July 30, 2025 02:27
This change introduces the ability to deploy multiple instances of the same function source, each with its own configuration.

This is achieved by allowing multiple function configurations in `firebase.json`. If multiple configurations are present, each must have a unique `codebase` identifier.

This change is the first step towards implementing "Function Kits", which will allow developers to easily add pre-built backend functionality to their Firebase projects.

This change is backward-compatible. Existing `firebase.json` configurations will continue to work as before.
This change introduces two new validation rules for function configurations in `firebase.json`:

1.  The `prefix` property, if specified, must only contain lowercase letters, numbers, and hyphens.
2.  The combination of `source` and `prefix` must be unique across all function configurations.

These changes ensure that function deployments with prefixes are valid and that there are no conflicts when deploying multiple functions from the same source directory.
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 significantly enhances the flexibility and robustness of Firebase Functions configurations by introducing support for function name prefixes. The primary goal is to enable developers to define and deploy multiple distinct function configurations from a single source directory, while simultaneously enforcing strict validation rules on these prefixes to prevent naming collisions and ensure deployment integrity. This change impacts both the configuration schema and the core logic for building, deploying, and emulating functions.

Highlights

  • New prefix property for Functions: Introduced a new optional prefix property for function configurations within firebase.json. This allows developers to define a prefix that will be prepended to the function's ID during deployment, enabling more flexible naming conventions and supporting multiple function configurations from the same source directory.
  • Prefix Validation Rules: Implemented strict validation for the new prefix property. The prefix must now consist only of lowercase letters, numbers, and hyphens, and has a maximum length of 30 characters. This ensures valid and consistent function naming.
  • Unique Source/Prefix Combination Enforcement: Added a crucial validation rule that requires the combination of a function's source directory and its prefix to be unique across all function configurations. This prevents naming conflicts when deploying multiple functions that share the same source code but are intended to be distinct entities.
  • Emulator and Build Process Integration: Updated the Firebase Functions emulator and the build/deployment pipeline to correctly recognize and apply the new prefix property. This ensures that functions are correctly named and discoverable both during local development and actual deployments.
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 or fill out our survey 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

  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 introduces validation for function prefixes and ensures uniqueness for source/prefix pairs, which is a valuable addition for managing complex function deployments. The implementation is solid and well-tested. I have a few suggestions to enhance the robustness of the validation and improve test coverage. My main concern is with the prefix validation logic, which could allow for invalid function names to be constructed. I've provided a critical-severity comment with a suggested fix for this. I've also suggested a minor code simplification and an additional test case to cover an important edge case. Overall, great work on this feature!

taeold and others added 3 commits July 29, 2025 20:49
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit includes several improvements to the function configuration validation:

-   The error message for duplicate `source`/`prefix` pairs is now more descriptive and suggests a solution.
-   The test suite is more robust, with more specific error message checks and improved typing.
-   Linter warnings have been addressed.
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