-
Notifications
You must be signed in to change notification settings - Fork 431
fix(kits): restore extension select params for yes/no config parity #3148
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75f3807
fix(kits): restore extension select params
CorieW 0c335c6
test(kits): fold the config-parity suites into the kits' config tests
CorieW 32e9495
Merge branch 'kits' into fix/kits-restore-extension-select-params
CorieW 9385a86
fix(kits): keep boolean params for the true/false selects
CorieW 30f189f
Merge remote-tracking branch 'origin/kits' into fix/kits-restore-exte…
CorieW e8a954a
fix(storage-resize-images): preselect the extension default for MAKE_…
CorieW 86e2f92
Merge branch 'kits' into fix/kits-restore-extension-select-params
CorieW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| - fix: `ENABLE_AUTO_DISCOVERY` accepts the extension's `yes` / `no` values again. The kit had declared it as a boolean param, which only counts the literal `true` as enabled, so a `.env` copied from an installed extension instance carried `yes` and silently left auto-discovery switched off. The param is now the extension's labeled `Yes` / `No` select and is read the same way the extension read it. | ||
| - Initial release of kit, see README for differences between the legacy extension and this kit | ||
| - The instance id now comes from `FIREBASE_KIT_INSTANCE_ID`, which the Firebase CLI (15.27.0 or later) provides to each kit instance; `INSTANCE_ID` is no longer a configuration parameter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,9 @@ class FakeStringParam extends FakeExpression<string> { | |
| } | ||
|
|
||
| value(): string { | ||
| if (process.env[this.name] !== undefined) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: reading |
||
| return process.env[this.name]; | ||
| } | ||
| if (this.defaultValue instanceof FakeStringParam) { | ||
| return this.defaultValue.value(); | ||
| } | ||
|
|
@@ -54,8 +57,13 @@ const defineInt = vi.fn((name: string, opts?: { default?: number }) => ({ | |
| value: () => opts?.default ?? 0, | ||
| })); | ||
|
|
||
| const defineBoolean = vi.fn((_name: string, opts?: { default?: boolean }) => ({ | ||
| value: () => opts?.default ?? false, | ||
| const select = vi.fn((options: Record<string, string>) => ({ | ||
| select: { | ||
| options: Object.entries(options).map(([label, value]) => ({ | ||
| label, | ||
| value, | ||
| })), | ||
| }, | ||
| })); | ||
|
|
||
| function cel(value: unknown): string { | ||
|
|
@@ -64,19 +72,18 @@ function cel(value: unknown): string { | |
|
|
||
| vi.mock("firebase-functions/params", () => ({ | ||
| Expression: FakeExpression, | ||
| defineBoolean, | ||
| defineInt, | ||
| defineString, | ||
| projectID: { value: () => "demo-test" }, | ||
| select: vi.fn((options: string[]) => ({ options })), | ||
| select, | ||
| storageBucket: new FakeStringParam("STORAGE_BUCKET", "demo-test.appspot.com"), | ||
| })); | ||
|
|
||
| async function importConfig() { | ||
| vi.resetModules(); | ||
| defineString.mockClear(); | ||
| defineInt.mockClear(); | ||
| defineBoolean.mockClear(); | ||
| select.mockClear(); | ||
| vi.stubEnv("FIREBASE_KIT_INSTANCE_ID", "test-instance"); | ||
|
|
||
| return import("../src/config"); | ||
|
|
@@ -112,6 +119,16 @@ describe("configFromEnv", () => { | |
| expect(config.searchDepth).toBeUndefined(); | ||
| }); | ||
|
|
||
| test("parses the predecessor's yes/no values", async () => { | ||
| const { configFromEnv } = await importConfig(); | ||
|
|
||
| vi.stubEnv("ENABLE_AUTO_DISCOVERY", "yes"); | ||
| expect(configFromEnv().enableAutoDiscovery).toBe(true); | ||
|
|
||
| vi.stubEnv("ENABLE_AUTO_DISCOVERY", "no"); | ||
| expect(configFromEnv().enableAutoDiscovery).toBe(false); | ||
| }); | ||
|
|
||
| test("declares the params the extension exposes", async () => { | ||
| await importConfig(); | ||
|
|
||
|
|
@@ -136,9 +153,19 @@ describe("configFromEnv", () => { | |
| "AUTO_DISCOVERY_SEARCH_DEPTH", | ||
| expect.objectContaining({ default: 3 }), | ||
| ]); | ||
| expect(defineBoolean.mock.calls).toContainEqual([ | ||
| expect(defineString.mock.calls).toContainEqual([ | ||
| "ENABLE_AUTO_DISCOVERY", | ||
| expect.objectContaining({ default: false }), | ||
| expect.objectContaining({ | ||
| default: "no", | ||
| input: { | ||
| select: { | ||
| options: [ | ||
| { label: "Yes", value: "yes" }, | ||
| { label: "No", value: "no" }, | ||
| ], | ||
| }, | ||
| }, | ||
| }), | ||
| ]); | ||
| }); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| - fix: `ENABLE_DISCUSSION_OPTION_OVERRIDES` and `ENABLE_GENKIT_MONITORING` accept the extension's `yes` / `no` values again. The kit had declared them as boolean params, which only count the literal `true` as enabled, so a `.env` copied from an installed extension instance carried `yes` and silently left per-discussion overrides and Genkit monitoring off. Both are now the extension's labeled `Yes` / `No` selects and are read the same way the extension read them. | ||
| - Initial release of kit, see README for differences between the legacy extension and this kit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /** | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Compatibility requirement, not aspiration: the extension declared these | ||
| * toggles as `yes` / `no` selects, so a deployed `.env` copied from an | ||
| * installed instance carries those literal values. | ||
| */ | ||
|
|
||
| import { declaredParams } from "firebase-functions/params"; | ||
| import { afterEach, beforeEach, describe, expect, test } from "vitest"; | ||
| import { configFromEnv } from "../src/config"; | ||
|
|
||
| function declaration(name: string) { | ||
| const param = declaredParams.find((candidate) => candidate.name === name); | ||
| if (!param || !("options" in param)) { | ||
| throw new Error(`Missing declaration for ${name}`); | ||
| } | ||
| const options = param.options as { default?: unknown; input?: unknown }; | ||
| return { | ||
| type: (param.constructor as unknown as { type: string }).type, | ||
| default: options.default, | ||
| input: options.input, | ||
| }; | ||
| } | ||
|
|
||
| const KEYS = [ | ||
| "ENABLE_DISCUSSION_OPTION_OVERRIDES", | ||
| "ENABLE_GENKIT_MONITORING", | ||
| "FIREBASE_CONFIG", | ||
| ] as const; | ||
|
|
||
| describe("select values inherited from the extension", () => { | ||
| const saved = new Map<string, string | undefined>(); | ||
|
|
||
| test("declares the predecessor's labeled string selects", () => { | ||
| for (const name of [ | ||
| "ENABLE_DISCUSSION_OPTION_OVERRIDES", | ||
| "ENABLE_GENKIT_MONITORING", | ||
| ]) { | ||
| expect(declaration(name)).toEqual({ | ||
| type: "string", | ||
| default: "no", | ||
| input: { | ||
| select: { | ||
| options: [ | ||
| { label: "Yes", value: "yes" }, | ||
| { label: "No", value: "no" }, | ||
| ], | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| for (const key of KEYS) { | ||
| saved.set(key, process.env[key]); | ||
| delete process.env[key]; | ||
| } | ||
| // The project id resolves out of the runtime-injected FIREBASE_CONFIG. | ||
| process.env.FIREBASE_CONFIG = JSON.stringify({ projectId: "demo-test" }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| for (const [key, value] of saved) { | ||
| if (value === undefined) { | ||
| delete process.env[key]; | ||
| } else { | ||
| process.env[key] = value; | ||
| } | ||
| } | ||
| saved.clear(); | ||
| }); | ||
|
|
||
| test("reads ENABLE_DISCUSSION_OPTION_OVERRIDES as yes/no", () => { | ||
| process.env.ENABLE_DISCUSSION_OPTION_OVERRIDES = "yes"; | ||
| expect(configFromEnv().enableOverrides).toBe(true); | ||
|
|
||
| process.env.ENABLE_DISCUSSION_OPTION_OVERRIDES = "no"; | ||
| expect(configFromEnv().enableOverrides).toBe(false); | ||
| }); | ||
|
|
||
| test("reads ENABLE_GENKIT_MONITORING as yes/no", () => { | ||
| process.env.ENABLE_GENKIT_MONITORING = "yes"; | ||
| expect(configFromEnv().enableGenkitMonitoring).toBe(true); | ||
|
|
||
| process.env.ENABLE_GENKIT_MONITORING = "no"; | ||
| expect(configFromEnv().enableGenkitMonitoring).toBe(false); | ||
| }); | ||
|
|
||
| test("treats an unset variable as off, as the extension did", () => { | ||
| const config = configFromEnv(); | ||
|
|
||
| expect(config.enableOverrides).toBe(false); | ||
| expect(config.enableGenkitMonitoring).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: bare
=== "yes"is exact parity with the extension, so fine to keep. Just flagging that #3145 landed a trimming/lowercasingyesNo()helper in bigquery-export (src/config.ts:640) for the same shape, so we now have two conventions. Not for this PR, but I think we should pick one and apply it everywhere in a follow-up, otherwise a hand-editedYESbehaves differently per kit. Same applies to the two in chatbotconfig.ts:377-378.