fix: trust discovered entry points for hyphenated functions#10572
fix: trust discovered entry points for hyphenated functions#10572IzaakGough wants to merge 2 commits into
Conversation
Unlinking the password provider was incorrectly clearing email, emailVerified, and emailLinkSignin. This caused users to display in the auth dashboard without an email. The behaviour also differed from prod firebase behavior in that it was possible to sign a user up, unlink the password provider, and then sign the user up again using the same email address. In prod this generates a 400 response. Resolves #10517
There was a problem hiding this comment.
Code Review
This pull request ensures that hyphenated entry points are preserved in Cloud Functions v2 and the local functions emulator shell, rather than replacing hyphens with dots. It also fixes an issue in the Auth emulator where deleting a password provider incorrectly cleared the user's email. A review comment suggests replacing any with unknown in the newly extracted initializeFunctionsShellContext function to align with the repository's TypeScript style guide.
| const serveFunctions = new FunctionsServer(); | ||
|
|
||
| export const initializeFunctionsShellContext = ( | ||
| context: Record<string, any>, |
There was a problem hiding this comment.
According to the repository style guide (TypeScript section, line 38), any should not be used as an escape hatch. Since the context object is a dynamic key-value store where we only write values, we should use Record<string, unknown> instead of Record<string, any>. This is also consistent with the test file src/functionsShellCommandAction.spec.ts which already types the context as Record<string, unknown>.
| context: Record<string, any>, | |
| context: Record<string, unknown>, |
References
- Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)
|
Closing in favor of #10573 |
Related to
firebase/firebase-tools#8469Companion SDK PR:
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:
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.