fix: trust discovered entry points for hyphenated functions#10573
fix: trust discovered entry points for hyphenated functions#10573IzaakGough wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Firebase Functions Shell and Cloud Functions v2 deployment to preserve hyphenated entry points instead of replacing hyphens with dots. It refactors the shell context initialization to use trigger.entryPoint directly and updates FUNCTION_TARGET accordingly, accompanied by new unit tests. The review feedback suggests replacing the any type in the context parameter of initializeFunctionsShellContext with unknown to align with the repository's TypeScript style guidelines.
| const serveFunctions = new FunctionsServer(); | ||
|
|
||
| export const initializeFunctionsShellContext = ( | ||
| context: Record<string, any>, |
There was a problem hiding this comment.
According to the repository style guide (GEMINI.md, line 38), any should not be used as an escape hatch. Since context is a REPL context object that can hold arbitrary values, we should type it as Record<string, unknown> instead of Record<string, any>.
| context: Record<string, any>, | |
| context: Record<string, unknown>, |
References
- Never use
anyorunknownas an escape hatch. Define proper interfaces/types or use type guards. (link)
Related to #8469
Companion SDK PR: #1896
This PR updates
firebase-toolsto trust theentryPointemitted byfirebase-functionsdiscovery instead of re-deriving it from function ids.Problem
The companion
firebase-functionschange fixes discovery for quoted export names containing hyphens, for example:After that SDK fix, the discovered
entryPointis correctly preserved asdummystore-bot.However,
firebase-toolsstill had two places that assumed hyphens should be converted into dot notation:FUNCTION_TARGETby rewritingentryPointwith- -> .functions:shellreconstructed shell bindings fromtrigger.nameinstead of using the discoveredtrigger.entryPointThat behavior is still correct for grouped exports like
grouped.fn, but it is incorrect for flat quoted export names that literally contain hyphens.Change
This PR makes
firebase-toolsuse the SDK-providedentryPointas the source of truth.Gen2 deploy
cloudfunctionsv2now sets:FUNCTION_TARGET = buildConfig.entryPointwithout rewriting hyphens to dots.
Functions shell
functions:shellnow initializes REPL bindings fromtrigger.entryPointrather than deriving a path fromtrigger.name.This preserves both behaviors correctly:
grouped.fndummystore-botTests
This PR adds or updates coverage for:
FUNCTION_TARGETtrigger.entryPointfor both:Relationship To
firebase-functionsThis PR is the CLI-side follow-up to the primary SDK fix in
firebase-functions.On its own, this change improves correctness whenever
entryPointis already accurate. Together with the companionfirebase-functionsPR, it fixes the full quoted-hyphen export flow end to end.Companion PR: #1896
Validation
Validated with:
cloudfunctionsv2and shell-context regression testsfirebase-functionsfixnpm packon localfirebase-functionsfirebase-toolsnpm packon localfirebase-toolsThat deploy successfully recognized and updated a function named
dummystore-bot.