Skip to content

fix: trust discovered entry points for hyphenated functions#10572

Closed
IzaakGough wants to merge 2 commits into
mainfrom
@invertase/fix-function-names-which-include-hyphens
Closed

fix: trust discovered entry points for hyphenated functions#10572
IzaakGough wants to merge 2 commits into
mainfrom
@invertase/fix-function-names-which-include-hyphens

Conversation

@IzaakGough
Copy link
Copy Markdown

Related to firebase/firebase-tools#8469

Companion SDK PR:

This PR updates firebase-tools to trust the entryPoint emitted by firebase-functions discovery instead of re-deriving it from function ids.

Problem

The companion firebase-functions change fixes discovery for quoted export names containing hyphens, for example:

const func = onRequest((req, res) => {
  res.send("ok");
});

export { func as "dummystore-bot" };

After that SDK fix, the discovered entryPoint is correctly preserved as dummystore-bot.

However, firebase-tools still had two places that assumed hyphens should be converted into dot notation:

  • gen2 deploy code set FUNCTION_TARGET by rewriting entryPoint with - -> .
  • functions:shell reconstructed shell bindings from trigger.name instead of using the discovered trigger.entryPoint

That 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-tools use the SDK-provided entryPoint as the source of truth.

Gen2 deploy

cloudfunctionsv2 now sets:

  • FUNCTION_TARGET = buildConfig.entryPoint

without rewriting hyphens to dots.

Functions shell

functions:shell now initializes REPL bindings from trigger.entryPoint rather than deriving a path from trigger.name.

This preserves both behaviors correctly:

  • grouped exports continue to bind as nested paths like grouped.fn
  • quoted export names with hyphens remain flat bindings like dummystore-bot

Tests

This PR adds or updates coverage for:

  • gen2 deploy requests preserving a hyphenated FUNCTION_TARGET
  • shell context initialization using trigger.entryPoint for both:
    • flat hyphenated names
    • grouped dotted entry points

Relationship To firebase-functions

This PR is the CLI-side follow-up to the primary SDK fix in firebase-functions.

On its own, this change improves correctness whenever entryPoint is already accurate. Together with the companion firebase-functions PR, it fixes the full quoted-hyphen export flow end to end.

Companion PR:

Validation

Validated with:

  • targeted cloudfunctionsv2 and shell-context regression tests
  • the companion local firebase-functions fix
  • a packaged end-to-end flow using:
    • npm pack on local firebase-functions
    • installing that tarball into local firebase-tools
    • npm pack on local firebase-tools
    • deploying from a throwaway test project using the packed CLI and packed SDK

That deploy successfully recognized and updated a function named dummystore-bot.

swseverance and others added 2 commits May 19, 2026 09:38
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
Copy link
Copy Markdown
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 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>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>.

Suggested change
context: Record<string, any>,
context: Record<string, unknown>,
References
  1. Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)

@IzaakGough
Copy link
Copy Markdown
Author

Closing in favor of #10573

@IzaakGough IzaakGough closed this May 28, 2026
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.

3 participants