Skip to content

Reprint pull: fix bugs found before making it the default - #6157

Closed
chubes4 wants to merge 5 commits into
trunkfrom
chubes/reprint-pull-audit
Closed

chubes4 wants to merge 5 commits into
trunkfrom
chubes/reprint-pull-audit

Conversation

@chubes4

@chubes4 chubes4 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Related issues

  • Related to the Reprint pull rollout (removing STUDIO_ENABLE_PULL_REPRINT). The settings opt-out comes in a separate PR.

How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, did the usage audit and stress-tested studio pull against real WordPress.com Atomic and preview sites with Reprint enabled. It found each bug by reproducing it on a real site, then wrote the fixes and tests. Chris reviews before merge.

Proposed Changes

Bugs found while stress-testing Reprint pull before it becomes the default:

  • App-initiated push and pull failures never reached Sentry. The app starts the CLI with STUDIO_HOST_REPORTS_CLI_ERRORS=1, so the CLI leaves reporting to the app (Report errors to Sentry from the CLI, studio ui and the web build #5922), but the app's sync IPC handlers never reported anything. Failures are now captured with sync_direction, sync_provider and pull_engine (reprint/backup) tags. Cancels are not reported, and expected errors are still dropped by beforeSend. This affects the current Backup pull too.
  • A re-pull deleted files the user added locally. pull-files --mode=mirror removed anything not on the remote, such as a theme created locally after the first pull. Later pulls now pass --on-fs-root-nonempty=preserve-local: files from the remote are still restored to match it, and files the user added are kept. The Backup pull never deleted local files, so without this fix switching engines changes behavior and loses data.
  • Sites WordPress.com lists with an http:// address could not be pulled. Reprint refuses HTTP API URLs. Atomic sites serve HTTPS, so the exporter URL is now always HTTPS.
  • One failed --only selection blocked every later pull of that site. Studio saved the selection before the pull and reused it whenever an interrupted pull existed, so --only nonexistent/path kept failing even after rerunning with --options all. The saved selection now applies only when no selection is given (a bare studio pull resume). A different selection aborts the interrupted pull and starts over.
  • The resume hint after a failed first pull didn't work. Studio remembers the remote only after a successful pull, so studio pull --path … without --remote-site fails with "Multiple WordPress.com sites are available". The hint now includes --remote-site <id>.

Testing Instructions

With STUDIO_ENABLE_PULL_REPRINT=1, using the CLI built from this branch:

  1. Pull an Atomic site into a new local site. Add wp-content/themes/my-local-theme/style.css, edit one theme file that came from the remote, then pull again. The local theme stays, and the edited file is restored to match the remote.
  2. Pull a site whose WordPress.com URL is http://…. It pulls (on trunk: "The remote Reprint API URL you provided uses HTTP").
  3. Make a first pull fail, for example --only nonexistent/path. Run the printed resume command and it pulls. Then run it with --options all: the earlier selection is discarded and the full site pulls.
  4. From the app, make a pull fail. The error reaches Sentry with the pull_engine tag.

Other checks that passed on real sites: Ctrl-C during the database step then resume; SIGKILL partway through, then pulling a different remote into the same site (the result matched a fresh pull file for file); two pulls into the same site at once (the second is cleanly refused by Reprint's state lock); preview sources; --skip-database, --skip-files, --only; a local path with spaces and accented characters.

Platforms: macOS, Linux (Ubuntu), and a Windows 11 VM. On Windows, a re-pull removed wp-content. That bug is in Reprint (WordPress/reprint#1020): the remote index came out unsorted after Windows deferred its links. With a phar built from that branch, re-pulls on Windows keep wp-content and the files added locally.

Unit tests: npx vitest run apps/cli/lib/pull apps/cli/commands/tests/pull.test.ts apps/studio/src/modules/sync/lib/tests packages/providers/wpcom/sites/tests. The new IPC handler test fails on trunk.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

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

Auto-approved: chubes4 is a trusted author.

@chubes4

chubes4 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Split into one PR per fix so each can be reviewed and shipped on its own:

Windows re-pull fix: WordPress/reprint#1020 (needs a Reprint release and a version bump in Studio). Still to come: one Reprint key per machine, then Reprint as the default pull engine with a settings opt-out.

(Comment by Claude Opus 5.5 via Claude Code, on behalf of Chris Huber.)

@chubes4 chubes4 closed this Nov 24, 2026
chubes4 added a commit that referenced this pull request Nov 30, 2026
## Related issues

- Part of the Reprint pull rollout (removing
`STUDIO_ENABLE_PULL_REPRINT`). Split out of #6157.

## How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found
this while stress-testing Reprint pull on real WordPress.com Atomic and
preview sites, then wrote the fix and tests. It was split out of #6157.
Chris reviews before merge.

## Proposed Changes

- App-initiated push and pull failures never reached Sentry. The app
starts the CLI with `STUDIO_HOST_REPORTS_CLI_ERRORS=1`, so the CLI
leaves reporting to the app (#5922). The app's sync IPC handlers never
reported anything, though. Failures are now captured with
`sync_direction`, `sync_provider` and `pull_engine` (`reprint`/`backup`)
tags. Cancels are not reported, and expected errors are still dropped by
`beforeSend`.
- This affects the Backup pull that ships today as well, which is why
Sentry shows no pull failures even though Tracks records a 31% failure
rate for Legacy pulls.

## Testing Instructions

1. From the app, make a pull fail.
2. The error reaches Sentry with the `sync_direction`, `sync_provider`
and `pull_engine` tags. Cancelling a pull sends nothing.

Unit tests: `npx vitest run apps/studio/src/modules/sync/lib/tests`. The
new IPC handler test fails on trunk.

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
chubes4 added a commit that referenced this pull request Nov 30, 2026
## Related issues

- Part of the Reprint pull rollout (removing
`STUDIO_ENABLE_PULL_REPRINT`). Split out of #6157.

## How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found
this while stress-testing Reprint pull on real WordPress.com Atomic and
preview sites, then wrote the fix and tests. It was split out of #6157.
Chris reviews before merge.

## Proposed Changes

- The resume hint printed after a failed first pull didn't work. Studio
remembers the remote only after a successful pull, so `studio pull
--path …` without `--remote-site` fails with "Multiple WordPress.com
sites are available". The hint now includes `--remote-site <id>`.

## Testing Instructions

With `STUDIO_ENABLE_PULL_REPRINT=1`, interrupt a first pull (Ctrl-C
partway through). Run the printed resume command as-is: it resumes the
pull (on trunk it fails with "Multiple WordPress.com sites are
available").

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
chubes4 added a commit that referenced this pull request Nov 30, 2026
## Related issues

- Part of the Reprint pull rollout (removing
`STUDIO_ENABLE_PULL_REPRINT`). Split out of #6157.

## How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found
this while stress-testing Reprint pull on real WordPress.com Atomic and
preview sites, then wrote the fix and tests. It was split out of #6157.
Chris reviews before merge.

## Proposed Changes

- One failed `--only` selection blocked every later pull of that site.
Studio saved the selection before the pull and reused it whenever an
interrupted pull existed, so `--only nonexistent/path` kept failing even
after rerunning with `--options all`.
- The saved selection now applies only when no selection is given (a
bare `studio pull` resume). A different selection aborts the interrupted
pull and starts over.

## Testing Instructions

With `STUDIO_ENABLE_PULL_REPRINT=1`:

1. Run `studio pull --remote-site <id> --only nonexistent/path`. It
fails.
2. Run it again with `--options all`. On trunk it fails again with the
old selection. With this change, the earlier selection is discarded and
the full site pulls.
3. Interrupt a pull and run a bare `studio pull`: it resumes with the
saved selection.

Checked on macOS, Linux (Ubuntu) and a Windows 11 VM. On Linux, an
interrupted and resumed pull ended with the same 23,365 files as a full
pull.

Unit tests: `npx vitest run apps/cli/lib/pull
apps/cli/commands/tests/pull.test.ts`.

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
chubes4 added a commit that referenced this pull request Nov 30, 2026
## Related issues

- Part of the Reprint pull rollout (removing
`STUDIO_ENABLE_PULL_REPRINT`). Split out of #6157.

## How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found
this while stress-testing Reprint pull on real WordPress.com Atomic and
preview sites, then wrote the fix and tests. It was split out of #6157.
Chris reviews before merge.

## Proposed Changes

- Sites that WordPress.com lists with an `http://` address could not be
pulled with Reprint, because Reprint refuses HTTP API URLs ("The remote
Reprint API URL you provided uses HTTP"). Atomic sites serve HTTPS, so
the exporter URL is now always HTTPS.

## Testing Instructions

With `STUDIO_ENABLE_PULL_REPRINT=1`, pull a site whose WordPress.com URL
is `http://…`. On trunk the pull fails with the HTTP error. With this
change it pulls. Reproduced on an Atomic test site listed as `http://`.

Unit tests: `npx vitest run packages/providers/wpcom/sites/tests`.

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
chubes4 added a commit that referenced this pull request Nov 30, 2026
## Related issues

- Part of the Reprint pull rollout (removing
`STUDIO_ENABLE_PULL_REPRINT`). Split out of #6157.

## How AI was used in this PR

Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found
this while stress-testing Reprint pull on real WordPress.com Atomic and
preview sites, then wrote the fix and tests. It was split out of #6157.
Chris reviews before merge.

## Proposed Changes

- A Reprint re-pull deleted files the user added locally. `pull-files
--mode=mirror` removed anything not on the remote, such as a theme
created locally after the first pull. Later pulls now pass
`--on-fs-root-nonempty=preserve-local`: files from the remote are still
restored to match it, and files the user added are kept.
- The Backup pull never deleted local files, so without this change
switching engines would lose user data.

## Testing Instructions

With `STUDIO_ENABLE_PULL_REPRINT=1`:

1. Pull an Atomic site into a new local site.
2. Add `wp-content/themes/my-local-theme/style.css`, and edit one theme
file that came from the remote.
3. Pull again. The local theme stays (on trunk it is deleted), and the
edited file is restored to match the remote.

Checked on macOS, Linux (Ubuntu) and a Windows 11 VM. On Windows,
re-pulls also need WordPress/reprint#1020, which fixes a Reprint bug
that removed `wp-content`.

Unit tests: `npx vitest run apps/cli/lib/pull
apps/cli/commands/tests/pull.test.ts`.

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
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.

1 participant