Adds missing Params support in v1 configurability#1820
Adds missing Params support in v1 configurability#1820
Conversation
Requires adding support for new features such as string interpolation (API propsoal oustanding) and value-only transforms (API proposal not outstanding beause the API is not publicly released)
Summary of ChangesHello, 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 configurability of Firebase Functions v1 by introducing support for dynamic parameter values. It enables developers to use string interpolation and value-only transformations within function definitions, leading to more flexible and reusable function configurations across different services. Highlights
🧠 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
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.
Code Review
This pull request adds significant configurability to v1 functions by introducing support for Expression types in trigger definitions, including a new expr template literal for string interpolation and a transform function for runtime value manipulation. The changes are extensive and well-applied across different providers. I've identified one high-severity issue in TransformedStringExpression that could lead to invalid CEL generation, and I've provided a suggestion to fix it. Overall, this is a great enhancement.
src/params/types.ts
Outdated
| } | ||
|
|
||
| toString(): string { | ||
| return this.source instanceof Expression ? this.source.toCEL() : this.transformer(this.source); |
There was a problem hiding this comment.
The toString() implementation for TransformedStringExpression can lead to invalid CEL generation when used inside other expressions.
- When
sourceis anExpression,toString()incorrectly returnsthis.source.toCEL(), which includes{{...}}. This causes nested braces (e.g.,{{ {{...}} }}) when theTransformedStringExpressionis part of another expression. - When
sourceis astring,toString()returns the transformed string without quotes. This will be treated as an identifier instead of a string literal in the generated CEL.
The toString() method should return the unwrapped CEL for expressions and a properly quoted string for literals. A test case that would have caught this is:
it("handles transformed expressions inside other expressions", () => {
const p = params.defineString("P");
const t = transform(p, (s) => s.toUpperCase());
const b = params.defineBoolean("B");
expect(b.thenElse(t, "foo").toCEL()).to.equal('{{ params.B ? params.P : "foo" }}');
});| return this.source instanceof Expression ? this.source.toCEL() : this.transformer(this.source); | |
| return this.source instanceof Expression ? this.source.toString() : JSON.stringify(this.transformer(this.source)); |
Requires adding support for new features such as string interpolation (API propsoal oustanding) and value-only transforms (API proposal not outstanding beause the API is not publicly released)
Customers can now say cool things like:
For other language implications, see proposal.