Skip to content

Reprint export: Read export credentials past a stale notoptions cache - #55370

Closed
chubes4 wants to merge 1 commit into
trunkfrom
fix/reprint-export-stale-notoptions
Closed

chubes4 wants to merge 1 commit into
trunkfrom
fix/reprint-export-stale-notoptions

Conversation

@chubes4

@chubes4 chubes4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

  • Reprint export credentials (public key, secret) and the export window stamp are created the first time a site is pulled. On a persistent object cache, a concurrent request that loaded notoptions before that can write its copy back afterwards. From then on get_option() reports the option missing, though the row is in the database.
  • This matches what Studio sees on a site's first Reprint pull. The key installs fine, enable-export returns 200, and about a second later enable-export returns 409 jetpack_reprint_no_credential. Or, partway through a pull, export requests get the site's HTML homepage because the handler falls through. Installing the same key again fixes it, because add_option() takes the option out of notoptions. Later pulls aren't affected because the options already exist.
  • The exporter now reads its guarded options through read_option(). That helper uses get_option() and, only when the option comes back missing, checks the row in the database. Sites with a stored credential see no extra query.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • vendor/bin/phpunit -c phpunit.12.xml.dist --filter Reprint_Exporter_Test passes (92 tests).
  • The new test_state_survives_a_stale_notoptions_cache stores a key, opens the window, plants the stale notoptions a concurrent request would write, and checks that get_state() still reports the credential and an open window. It fails on trunk (Failed asserting that false is true) and passes with this change.
  • On Atomic: pull a site with Studio (Reprint engine) that has never been pulled before. The first pull should no longer fail with "did not accept the migration key", "Reprint Server plugin is not installed", or an HTML response in place of multipart.

The Atomic race itself hasn't been reproduced live yet. The failures were seen on sites being pulled for the first time, and this is the mechanism that fits them.


AI disclosure: Claude (Opus) in Claude Code traced the bug, wrote the fix and test, and drafted this description under Chris Huber's direction.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/reprint-export-stale-notoptions branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/reprint-export-stale-notoptions

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 23, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/src/reprint-export/class-reprint-exporter.php 132/147 (89.80%) 0.36% 0 💚

Full summary · PHP report · JS report

@chubes4

chubes4 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the race this targets could not be reproduced deterministically on Atomic (16 controlled trials, including under concurrent load, plus 4 real first pulls, all clean). No Jetpack change without a deterministic reproduction. (Comment by Claude Opus via Claude Code, on behalf of Chris Huber.)

@chubes4 chubes4 closed this Nov 24, 2026
@chubes4
chubes4 deleted the fix/reprint-export-stale-notoptions branch November 24, 2026 01:24
@github-actions github-actions Bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant