Skip to content

Conversation

@Initsogar
Copy link
Contributor

@Initsogar Initsogar commented Dec 13, 2025

Fixes BACKUP-298

When backups are intentionally deactivated (status: backups-deactivated), My Jetpack shows "The last backup attempt failed" which is confusing because the backup isn't failing—it's just turned off.

Proposed changes:

  • Detect when backups are deactivated and show a neutral, informative message instead of an error state
  • Override product status to return INACTIVE (neutral) instead of NEEDS_ATTENTION__ERROR for deactivated backups
  • Show simplified message: "Backup was manually turned off. Please contact support to reactivate it."
  • Link directly to support form with pre-filled subject and site URL.
  • Hide admin actions (no troubleshoot button) since this is intentional, not an error.
Before After
CleanShot 2025-12-15 at 22 47 48@2x CleanShot 2025-12-17 at 01 09 38@2x

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

https://linear.app/a8c/issue/BACKUP-298/#comment-85de1b46

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

No

Testing instructions:

Note

The easiest way to test this is locally by mocking the backups deactivated scenario as described below. An alternative way is to test using a site with backups deactivated (that had attempted at least one backup), but this will require some internal setup.

  • Add this to tools/docker/mu-plugins/0-snippets.php to mock the backups deactivated scenario:
add_filter( 'pre_http_request', function( $preempt, $args, $url ) {
	// Mock /rewind endpoint - backups deactivated scenario
	if ( false !== strpos( $url, '/rewind?force=wpcom' ) && false === strpos( $url, '/rewind/backups' ) ) {
		return array(
			'response' => array( 'code' => 200 ),
			'body'     => wp_json_encode( array(
				'state'        => 'active',
				'last_updated' => '2025-12-13T04:52:18.461+00:00',
			)),
		);
	}

	// Mock /rewind/backups endpoint - backups deactivated status
	if ( false !== strpos( $url, '/rewind/backups' ) ) {
		return array(
			'response' => array( 'code' => 200 ),
			'body'     => wp_json_encode( array(
				array(
					'id'           => '803919785',
					'started'      => '2025-12-12 22:51:16',
					'last_updated' => '2025-12-12 22:51:16',
					'status'       => 'backups-deactivated',
					'period'       => '1765579871',
					'percent'      => '0',
					'is_backup'    => '1',
					'is_scan'      => '1',
				),
			)),
		);
	}

	return $preempt;
}, 10, 3 );
  • Clear transient: jetpack docker exec wp transient delete 'my-jetpack-backup-status'
  • Navigate to My Jetpack at /wp-admin/admin.php?page=my-jetpack

Expected behavior:

  • Card shows inactive state (neutral, not red error state) as the screenshot shared above
  • Card displays the message: "Backup was manually turned off. Please contact support to reactivate it."
  • No error icon should be displayed
  • No troubleshoot/admin buttons should be shown
  • Clicking "contact support" should open https://jetpack.com/contact-support/ with:
    • Pre-filled subject: "Please reactivate Backup on my site"
    • Pre-filled site URL in the form

Validating other scenarios:
You can update the latest backup status away from backups-deactivated to ensure other scenarios works as expected, like:

Status Screenshot
error CleanShot 2025-12-17 at 23 05 38@2x
finished CleanShot 2025-12-17 at 23 06 32@2x

After updating the snippet, remember to delete the my-jetpack-backup-status transient :)

jetpack docker exec wp transient delete 'my-jetpack-backup-status'

@Initsogar Initsogar self-assigned this Dec 13, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 13, 2025

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/my-jetpack-backups-deactivated-card branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/my-jetpack-backups-deactivated-card

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
Copy link
Contributor

github-actions bot commented Dec 13, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 Dec 13, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 13, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/my-jetpack/_inc/components/product-card/index.tsx 0/37 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/my-jetpack/_inc/components/product-cards-section/backup-card/index.jsx 0/49 (0.00%) 0.00% 3 ❤️‍🩹
projects/packages/my-jetpack/src/products/class-backup.php 88/171 (51.46%) 0.86% 1 ❤️‍🩹

Full summary · PHP report · JS report

@Initsogar Initsogar force-pushed the fix/my-jetpack-backups-deactivated-card branch 2 times, most recently from cdcfcdb to 23b4128 Compare December 18, 2025 02:46
@Initsogar Initsogar force-pushed the fix/my-jetpack-backups-deactivated-card branch from 23b4128 to 44d854d Compare December 18, 2025 03:03
@Initsogar Initsogar changed the title My Jetpack: fix false "backup failed" error for deactivated backups My Jetpack: update Backup card to inactive when backups are deactivated Dec 18, 2025
@Initsogar Initsogar force-pushed the fix/my-jetpack-backups-deactivated-card branch 2 times, most recently from 162010f to 44d854d Compare December 18, 2025 04:00
@Initsogar Initsogar requested review from a team and keoshi December 18, 2025 04:18
@Initsogar Initsogar added [Status] Needs Review This PR is ready for review. and 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 Dec 18, 2025
@Initsogar Initsogar marked this pull request as ready for review December 18, 2025 04:19
@Initsogar Initsogar requested a review from a team December 18, 2025 04:20
@github-actions github-actions bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Dec 18, 2025
@Initsogar Initsogar added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review This PR is ready for review. and removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 18, 2025
@Initsogar
Copy link
Contributor Author

Hi @Automattic/triforce! When you get a chance, I’d appreciate it if you could take a look at this PR. Your My Jetpack experience would be super helpful 🙌

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This looks good to me.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a UX issue where My Jetpack incorrectly displays "The last backup attempt failed" error state when backups are intentionally deactivated (status: backups-deactivated). The fix detects this specific status and displays a neutral, informative message with a support contact link instead of an error state.

Key changes:

  • Override Backup product status to return INACTIVE instead of ERROR for deactivated backups
  • Display informative message: "Backup was manually turned off. Please contact support to reactivate it."
  • Link to support form with pre-filled subject and site URL

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
projects/packages/my-jetpack/src/products/class-backup.php Adds get_status() override to return INACTIVE for deactivated backups; modifies transient caching logic to cache all array statuses
projects/packages/my-jetpack/_inc/components/product-cards-section/backup-card/index.jsx Adds deactivated state detection and renders new support contact message instead of error UI
projects/packages/my-jetpack/_inc/components/product-card/index.tsx Adds useEffect to reset loading state when admin prop becomes false
projects/packages/my-jetpack/changelog/fix-backup-deactivated-card Changelog entry documenting the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +468 to +480
public static function get_status() {
// Get the default status from parent.
$status = parent::get_status();

// Check if backups are deactivated (not an error, just manually turned off).
$needs_attention = static::does_module_need_attention();
if ( is_array( $needs_attention ) && 'backups-deactivated' === $needs_attention['data']['status'] ) {
// Return INACTIVE status for deactivated backups (neutral, not attention-grabbing).
return \Automattic\Jetpack\My_Jetpack\Products::STATUS_INACTIVE;
}

return $status;
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The new get_status() method that handles the backups-deactivated scenario lacks test coverage. Since the Backup product has existing PHPUnit tests, this new behavior should be tested to ensure it correctly returns STATUS_INACTIVE when backups are deactivated and doesn't break other status scenarios.

Copilot uses AI. Check for mistakes.
}

if ( is_array( $backup_failed_status ) && $backup_failed_status['type'] === 'error' ) {
if ( is_array( $backup_failed_status ) ) {
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The condition was changed from checking if the array has type 'error' to always caching any array. This means non-error states like 'backups-deactivated' will now be cached with a 5-minute TTL instead of the 1-hour TTL. This creates inconsistency - error states should have shorter cache times for quicker updates, while stable states like deactivation should have longer cache times. Consider checking the backup status to determine appropriate cache duration.

Copilot uses AI. Check for mistakes.

// Check if backups are deactivated (not an error, just manually turned off).
$needs_attention = static::does_module_need_attention();
if ( is_array( $needs_attention ) && 'backups-deactivated' === $needs_attention['data']['status'] ) {
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

This logic has a potential issue: it checks the data structure without verifying that the 'data' key exists first. If 'data' is not set in the array, this will cause a PHP notice for accessing an undefined index. Add a check for isset($needs_attention['data']) before accessing the nested 'status' key.

Suggested change
if ( is_array( $needs_attention ) && 'backups-deactivated' === $needs_attention['data']['status'] ) {
if (
is_array( $needs_attention )
&& isset( $needs_attention['data'] )
&& is_array( $needs_attention['data'] )
&& isset( $needs_attention['data']['status'] )
&& 'backups-deactivated' === $needs_attention['data']['status']
) {

Copilot uses AI. Check for mistakes.
const { status, doesModuleNeedAttention } = detail;
const lastBackupFailed = !! doesModuleNeedAttention;
const { status: lastBackupStatus } = doesModuleNeedAttention || {};
const lastBackupStatus = doesModuleNeedAttention?.data?.status || {};
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The default value should be an empty string or undefined, not an empty object. The code assigns {} as a default when doesModuleNeedAttention?.data?.status is falsy, but later at line 95, it's compared to a string ('backups-deactivated'). An empty object {} will never equal a string, so this works, but it's semantically incorrect and could cause confusion. Consider using '' or undefined as the default value.

Suggested change
const lastBackupStatus = doesModuleNeedAttention?.data?.status || {};
const lastBackupStatus = doesModuleNeedAttention?.data?.status || '';

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +116
useEffect( () => {
if ( ! admin && isActionLoading ) {
setIsActionLoading( false );
}
}, [ admin, isActionLoading ] );
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

This useEffect creates an infinite loop risk. When admin becomes false and isActionLoading is true, the effect calls setIsActionLoading(false), which updates state and triggers a re-render. Since isActionLoading is in the dependency array, this could cause unnecessary re-renders. The effect should only run when admin changes from true to false, not on every render where both conditions are met. Consider using a ref to track the previous admin value or restructure the logic to avoid this pattern.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] My Jetpack [Status] Needs Review This PR is ready for review. [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants