Conversation
This goes for both ext:migrate and kit:install.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new validation function, validateNpmPackageExists, to verify that a specified NPM package or version exists in the registry before running migration or installation commands. The review feedback points out that the current implementation causes duplicate network requests and can produce misleading error messages for non-404 errors (such as network timeouts). To address this, the reviewer suggests implementing an internal validation cache to avoid redundant network calls, refining error handling to distinguish between actual 404 errors and other transient failures, and ensuring proper test isolation by clearing the cache between tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Previously, running
firebase functions:kits:install --package <pkg>(orfirebase ext:migratewhen reaching kit installation) with a non-existent package or unavailable version would proceed through third-party/shrinkwrap warnings, confirmation prompts, kit/instance naming prompts, and file scaffolding before failing atnpm install(or misleadingly reporting"does not have an npm-shrinkwrap.json file"and"Installation cancelled").This change:
validateNpmPackageExists(rawPkgName)insrc/functions/kits/install.ts, which validates the package specifier format (validateNpmPackageName) and verifies that the package/version exists in the npm registry vianpm view <pkg> version(distinguishing 404/not-found errors from transient/system errors).validateNpmPackageExistsonce at the entry point ofinstallKitOrInstancebefore checking existing kits, prompting, or scaffolding files.Scenarios Tested
src/functions/kits/install.spec.tsforvalidateNpmPackageExistsandinstallKitOrInstance(valid package, nonexistent package / 404, transient/system lookup errors, unavailable version on existing kit, invalid package name format).