Skip to content

fix: preserve quoted hyphenated export names in discovery#1895

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

fix: preserve quoted hyphenated export names in discovery#1895
IzaakGough wants to merge 3 commits into
masterfrom
@invertase/fix-function-names-which-include-hyphens

Conversation

@IzaakGough
Copy link
Copy Markdown

Fixes firebase/firebase-tools#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:

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 updates the runtime loader to preserve literal hyphens in entry points for flat export names by separating the endpoint ID and entry point prefixes. It also exposes the underlying raw request and disconnect signal within the Genkit action context in onCallGenkit. Feedback suggests a cleaner way to satisfy the ESLint require-yield rule in the new tests by using yield* [] instead of an unreachable yield statement.

Comment on lines +761 to +768
stream: (async function* () {
await output;
// This test intentionally doesn't emit any stream messages, but ESLint's `require-yield`
// rule requires at least one `yield` in a generator function.
return;
// eslint-disable-next-line no-unreachable
yield undefined;
})(),
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

Instead of using an unreachable yield statement and disabling the ESLint rule, you can use yield* [] to elegantly satisfy the require-yield rule. This avoids unreachable code and linter bypasses entirely.

        stream: (async function* () {
          await output;
          yield* [];
        })(),

@IzaakGough
Copy link
Copy Markdown
Author

Closing in favor of #1896

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

2 participants