Skip to content

fix: preserve quoted hyphenated export names in discovery#1896

Open
IzaakGough wants to merge 1 commit into
masterfrom
@invertase/fix-function-names-which-include-hyphens-clean
Open

fix: preserve quoted hyphenated export names in discovery#1896
IzaakGough wants to merge 1 commit into
masterfrom
@invertase/fix-function-names-which-include-hyphens-clean

Conversation

@IzaakGough
Copy link
Copy Markdown

@IzaakGough IzaakGough commented May 28, 2026

Fixes #8469

This change fixes function discovery for quoted export names that contain hyphens, for example:

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

export { func as "dummystore-bot" };

Problem

The current discovery logic derives entryPoint from the manifest endpoint id by replacing - with ..

That works for grouped exports, where a flattened manifest id like grouped-fn should map back to an entry point like grouped.fn.

However, it is incorrect for quoted export names that literally contain hyphens. In that case, the discovered function id is something like dummystore-bot, but converting that to dummystore.bot produces the wrong runtime entry point.

As a result, downstream tooling can fail to deploy or invoke these functions correctly.

Change

This PR updates runtime discovery to track two separate paths during stack extraction:

  • the manifest endpoint id, which remains hyphen-flattened for nested/grouped exports
  • the runtime entryPoint, which preserves the actual export access path

With this change:

  • grouped exports still behave as before
  • quoted export names with hyphens are preserved correctly
  • discovery emits the correct entryPoint for downstream consumers

Tests

This PR adds coverage for the fix in two places:

  • unit/spec coverage for extractStack
  • end-to-end bin/discovery coverage using an ESM fixture with a quoted hyphenated export name

Companion Change In firebase-tools

This is the primary fix.

There is a companion PR in firebase-tools that updates the CLI to trust the SDK-provided entryPoint instead of re-deriving it from function ids, and also updates functions:shell to use the discovered entryPoint.

Companion PR: #10573

Validation

Validated with:

  • local firebase-functions discovery tests
  • local firebase-tools follow-up changes
  • a packaged end-to-end deploy flow using:
    • npm pack on local firebase-functions
    • npm pack on local firebase-tools
    • a throwaway test project deploying a quoted export named dummystore-bot

That deploy succeeded and the function was recognized and deployed under the correct name.

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 refactors the runtime loader to preserve literal hyphens in entry points for flat export names. The extractStack function in src/runtime/loader.ts has been updated to use separate prefixes for endpoint IDs and entry points, preventing hyphens from being incorrectly replaced with dots. Additionally, corresponding unit and integration tests have been added to verify this behavior. There are no review comments, and I have no feedback to provide.

@cabljac
Copy link
Copy Markdown
Contributor

cabljac commented May 29, 2026

/gemini review

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 modifies the extractStack function in src/runtime/loader.ts to separate the prefix logic into endpointIdPrefix and entryPointPrefix. This change ensures that literal hyphens in flat export names are preserved in the entry point instead of being incorrectly replaced with dots, while nested object exports still correctly use dot notation. Unit and integration tests have been added to verify this behavior. There are no review comments, and I have no additional feedback to provide.

@IzaakGough IzaakGough marked this pull request as ready for review June 1, 2026 04:34
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.

Issue with deploying onRequest cloud function as exports['dummystore-bot'] = onRequest(botApp)

2 participants