Skip to content

fix: correct function name length in validation error message to 63#10646

Open
ree-rishun wants to merge 4 commits into
firebase:mainfrom
ree-rishun:fix/function-name-length-error-message
Open

fix: correct function name length in validation error message to 63#10646
ree-rishun wants to merge 4 commits into
firebase:mainfrom
ree-rishun:fix/function-name-length-error-message

Conversation

@ree-rishun

@ree-rishun ree-rishun commented Jun 14, 2026

Copy link
Copy Markdown

Description

Fixes two inaccuracies in the function name validation error message in functionIdsAreValid() (src/deploy/functions/validate.ts). The message disagreed with both the validation regex /^[a-zA-Z][a-zA-Z0-9_-]{0,62}$/ and the function's own JSDoc comment:

  1. Character limit (62 → 63): The message said names must "not exceed 62 characters in length", but the regex allows 63 characters (1 leading letter + up to 62 additional characters), and the JSDoc comment also states "not exceed 63 characters in length". As a result, a 63-character function name deploys successfully, yet the message claimed the limit was 62 — misleading users into thinking valid names are invalid.

  2. Missing underscores: The message listed only "letters, numbers, hyphens", but the regex ([a-zA-Z0-9_-]) and the JSDoc comment both allow underscores. Underscores were silently omitted from the user-facing message.

This change updates the message so it is consistent with the regex, the JSDoc comment, and the messages already used elsewhere (e.g. applyPrefix() in src/deploy/functions/build.ts, which says "maximum length of 63 characters").

- numbers, hyphens, and not exceed 62 characters in length
+ numbers, underscores, hyphens, and not exceed 63 characters in length

Note: this validation also rejects names that don't start with a letter or contain other invalid characters. This PR only corrects the wording of the error message and does not change any validation behavior.

Scenarios Tested

  • Ran npm test locally; compilation and the existing test suite pass.
  • Deployed functions to a separate Firebase project and confirmed in the console that the deploys succeeded for both a 63-character name and a name containing underscores (e.g. my_func), verifying that 63 is the true limit (not 62) and that underscores are allowed.
  • This is a message-only change; no validation logic was modified.
$ TZ='America/Los_Angeles' npm test

... (truncated) ...

  4506 passing (38s)
  10 pending

... (coverage table truncated) ...

Sample Commands

No command or flag changes. The corrected error surfaces during deploy:

$ firebase deploy --only functions
Error: 1nnnnnnnnn function name(s) can only contain letters, numbers, underscores, hyphens, and not exceed 63 characters in length

@google-cla

google-cla Bot commented Jun 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the validation error message in src/deploy/functions/validate.ts to reflect the correct maximum length of 63 characters for function names. The reviewer pointed out that the error message should also be updated to include underscores, which are allowed by the validation regex.

Comment thread src/deploy/functions/validate.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@IzaakGough IzaakGough left a comment

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.

This looks good to me, nice work! The failing CI check is unrelated to this PR.

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@7e8582d). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10646   +/-   ##
=======================================
  Coverage        ?   57.72%           
=======================================
  Files           ?      608           
  Lines           ?    39112           
  Branches        ?     7839           
=======================================
  Hits            ?    22579           
  Misses          ?    14726           
  Partials        ?     1807           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ree-rishun ree-rishun requested a review from IzaakGough June 16, 2026 18:19
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.

4 participants