Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DIY migration failing to fetch migration key and throwing 403 on page reload #40270

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

Imran92
Copy link
Contributor

@Imran92 Imran92 commented Nov 20, 2024

Fixes Automattic/wp-calypso#96510

Proposed changes:

  • Removed the 'read' check so that users can see the migration key multiple times

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  1. Start a migration choosing the "I'll do it myself" option in the "How do you want to migrate?" step. This can be done following the steps:
    1.1. Navigate to /start.
    1.2. Choose "Import existing content or website" in the goals step.
    1.3. Navigate through the flow, selecting to migrate from a WordPress site, and the "I'll do it myself" option.
  2. When you are in the migration instructions screen, check the key by clicking the closed eye icon, and then close the window.
  3. Navigate to /sites.
  4. Click on the site with the pending migration.
  5. Click on "Start your migration".
  6. In the migration instructions page, make sure you see the error or at least the key does not load for you. Also check the network tab for a call made to /wpcom-migration-key API and make sure it has returned 403
  7. Now apply this branch to your newly created site using the Jetpack Beta Tester plugin following the instructions in White-labeled plugin: Add wpcom-migration key endpoint #39377 (comment). In this case, in the beta tester page, click the "Manage" button on the "WordPress.com Features" item, and then apply this branch
  8. Now try steps 4-6 again. This time, you shouldn't see any error. You should also be able to see and copy the migration key

@Imran92 Imran92 self-assigned this Nov 20, 2024
Copy link
Contributor

github-actions bot commented Nov 20, 2024

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 WordPress.com Simple 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, and enable the fix/migration-diy-throws-403-on-page-reload branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/migration-diy-throws-403-on-page-reload
    

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

Copy link
Contributor

github-actions bot commented Nov 20, 2024

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 Team 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

@Imran92 Imran92 changed the title Fix DIY migration failing to fetch migration key and throwing 403 on page reload [In Progress] Fix DIY migration failing to fetch migration key and throwing 403 on page reload Nov 20, 2024
@Imran92 Imran92 marked this pull request as ready for review November 20, 2024 09:54
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Nov 20, 2024
@Imran92 Imran92 requested a review from a team November 20, 2024 10:01
@Imran92 Imran92 added [Status] Needs Team Review and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Nov 20, 2024
@Imran92 Imran92 changed the title [In Progress] Fix DIY migration failing to fetch migration key and throwing 403 on page reload Fix DIY migration failing to fetch migration key and throwing 403 on page reload Nov 21, 2024
@Imran92 Imran92 requested a review from sixhours November 21, 2024 08:18
@donnapep
Copy link
Contributor

@Imran92 Looks like this one needs a rebase.

@Imran92 Imran92 force-pushed the fix/migration-diy-throws-403-on-page-reload branch from 6e356a7 to acd888f Compare November 29, 2024 15:25
@Imran92
Copy link
Contributor Author

Imran92 commented Dec 2, 2024

@donnapep thanks! I've rebased it

@donnapep
Copy link
Contributor

donnapep commented Dec 2, 2024

I've tried several times, but I'm not able to reproduce this error. There was a time where I saw it quite frequently, but even without this change, it seems to work for me. I guess I'll leave it for someone else to review to see if they can reproduce the error.

@Imran92
Copy link
Contributor Author

Imran92 commented Dec 2, 2024

I've tried several times, but I'm not able to reproduce this error. There was a time where I saw it quite frequently, but even without this change, it seems to work for me. I guess I'll leave it for someone else to review to see if they can reproduce the error.

Sure! Just to recheck - did you unhide the migration key after generating it? This error is generated only if you unhide it at lest once, and then retry loading the page

@@ -73,10 +73,6 @@ public function can_access() {
return false;
}

if ( 'read' === get_option( $this->key_is_read_option_name, false ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the key_is_read_option_name option is not used anymore. What do you think of cleaning up the related logic (removing the variable and the update_option call)?

Copy link
Member

@m1r0 m1r0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no issues reproducing it and the fix works as described! I've left one small suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when returning to the migration DIY flow
3 participants