fix: correct function name length in validation error message to 63#10646
fix: correct function name length in validation error message to 63#10646ree-rishun wants to merge 4 commits into
Conversation
|
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. |
There was a problem hiding this comment.
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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: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.
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()insrc/deploy/functions/build.ts, which says "maximum length of 63 characters").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
npm testlocally; compilation and the existing test suite pass.my_func), verifying that 63 is the true limit (not 62) and that underscores are allowed.Sample Commands
No command or flag changes. The corrected error surfaces during deploy: