Repository navigation
fix(hosting): implicitly resolve site project IDs in hosting:clone - #11275
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enables cross-project cloning for the hosting:clone command by allowing users to specify project IDs in the source and target arguments. It introduces resolveProjectId to automatically discover project IDs if they are omitted. The reviewer provided two actionable suggestions: parallelizing the project resolution network calls to improve performance and preserving the original error and status code when re-throwing FirebaseError to ensure correct error classification.
### Description In #11229, `hosting:clone` was updated to use project-scoped API requests and defaulted unspecified project IDs to `needProjectId(options)`. Because Firebase Hosting site IDs are globally unique, users previously cloned across projects without specifying the source project (e.g. `firebase hosting:clone site-a:live site-b:live --project=project-b`), which broke in 15.33.0 when `site-a` belonged to a different project than `--project`. This change updates `hosting:clone` to implicitly look up the owning project for a site via `getSite("-", siteId)` when a project ID is not explicitly provided in the `[<project>:]<site>:<channel>` or `[<project>:]<site>@<version>` argument. Once resolved, all subsequent API operations (`getChannel`, `createChannel`, `cloneVersion`, `createRelease`, `addAuthDomains`) continue to use the resolved project ID on project-scoped endpoints. Also updates the command help text and validation error messages to document the optional `<project>:` prefix. Fixes #11247 ### Scenarios Tested - Unit tests in `src/commands/hosting-clone.spec.ts`: - Same-project channel and version cloning. - Explicit cross-project cloning (`<project>:<site>:<channel>`). - Implicit cross-project cloning when source site is in a different project than `--project` (#11247). - Implicit project resolution when `--project` is omitted. - Error handling when a site is not found (404). ### Sample Commands ```bash firebase hosting:clone site-a:live site-b:live --project=project-b firebase hosting:clone site-a:live site-b:live firebase hosting:clone project-a:site-a:live project-b:site-b:live ```
joehan
approved these changes
Oct 13, 2026
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
In #11229,
hosting:clonewas updated to use project-scoped API requests and defaulted unspecified project IDs toneedProjectId(options). Because Firebase Hosting site IDs are globally unique, users previously cloned across projects without specifying the source project (e.g.firebase hosting:clone site-a:live site-b:live --project=project-b), which broke in 15.33.0 whensite-abelonged to a different project than--project.This change updates
hosting:cloneto implicitly look up the owning project for a site viagetSite("-", siteId)when a project ID is not explicitly provided in the[<project>:]<site>:<channel>or[<project>:]<site>@<version>argument. Once resolved, all subsequent API operations (getChannel,createChannel,cloneVersion,createRelease,addAuthDomains) continue to use the resolved project ID on project-scoped endpoints.Also updates the command help text and validation error messages to document the optional
<project>:prefix.Fixes #11247
Scenarios Tested
src/commands/hosting-clone.spec.ts:<project>:<site>:<channel>).--project(hosting:clone no longer finds a source site in another project (15.33.0) #11247).--projectis omitted.Sample Commands