Skip to content

Report app-initiated push and pull failures to Sentry - #6163

Merged
chubes4 merged 2 commits into
trunkfrom
chubes/sentry-sync-failures
Nov 30, 2026
Merged

chubes4 merged 2 commits into
trunkfrom
chubes/sentry-sync-failures

Conversation

@chubes4

@chubes4 chubes4 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Related issues

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 (Report errors to Sentry from the CLI, studio ui and the web build #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

  • 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 marked this pull request as ready for review November 24, 2026 02:09
@chubes4
chubes4 merged commit 6d44278 into trunk Nov 30, 2026
12 checks passed
@chubes4
chubes4 deleted the chubes/sentry-sync-failures branch November 30, 2026 13:46
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`). Follows #6163–#6167.

## 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 sites, then
wrote the fix and tests and ran the reproduction below. Chris reviews
before merge.

## Proposed Changes

- Two local sites pulling the same WordPress.com site at the same time
failed with `AUTH_UNKNOWN_KEY` (HTTP 403). Studio generated a Reprint
key per local site, and Jetpack keeps one key per site
(Automattic/jetpack#53537: "Installing a key replaces the previous
one"). The second pull installed its key over the first one's, and the
first pull's next request was refused.
- Studio now signs every Reprint pull with one key per machine,
`~/.studio/reprint-key.pem`, passed to `preflight`, `pull-files` and
`pull-db` as `--private-key-path`. Every local site on the machine
installs the same key, so they no longer replace each other's.
- The key is generated in Node (RSA 3072, the same as `reprint keygen`)
on first use. It is written to a temporary file and hard-linked into
place, so pulls that start at the same time end up with the same key.
This also removes the `pull-metadata` and `keygen` Reprint calls from
the start of each pull.
- Keys in existing per-site state directories are no longer used.
`--private-key-path` takes precedence over them, and the next pull
installs the machine key.
- Pulling one site from two different machines still conflicts, because
Jetpack keeps one key per site. That limit was a deliberate Jetpack
decision and is out of scope here.

## Testing Instructions

With `STUDIO_ENABLE_PULL_REPRINT=1`, start two pulls of the same remote
into two different local sites, about two seconds apart:

```
studio pull --path <site-a> --remote-site <id> --options all &
studio pull --path <site-b> --remote-site <id> --options all &
```

- On trunk (macOS, a preview site): the first pull succeeds and the
second fails at `files-pull` with `AUTH_UNKNOWN_KEY`.
- With this change: both pulls succeed, in two runs out of two. The
first run started with no `~/.studio/reprint-key.pem`. Afterwards there
is a single key file with mode `0600`.

Unit tests: `npx vitest run apps/cli/lib/pull
apps/cli/commands/tests/pull.test.ts`. The new test checks that three
pulls starting together get one key, and that it signs for the public
key it reports. The same key-creation code was also run on a Windows 11
VM, with the same result.

## 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