Skip to content

fix(hosting): implicitly resolve site project IDs in hosting:clone - #11275

Merged
bkendall merged 3 commits into
mainfrom
bkend-11247
Oct 13, 2026
Merged

bkendall merged 3 commits into
mainfrom
bkend-11247

Conversation

@bkendall

Copy link
Copy Markdown
Contributor

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:

Sample Commands

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

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

Comment thread src/commands/hosting-clone.ts Resolved
Comment thread src/commands/hosting-clone.ts Resolved
### 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
```
@bkendall
bkendall requested review from aalej and joehan October 13, 2026 22:05
@bkendall
bkendall marked this pull request as ready for review October 13, 2026 22:05
Comment thread src/commands/hosting-clone.ts Resolved
@bkendall
bkendall enabled auto-merge (squash) October 13, 2026 23:31
@bkendall
bkendall merged commit 3462e56 into main Oct 13, 2026
51 checks passed
@bkendall
bkendall deleted the bkend-11247 branch October 13, 2026 23:44
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.

hosting:clone no longer finds a source site in another project (15.33.0)

2 participants