-
Notifications
You must be signed in to change notification settings - Fork 800
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
Boost: Fix ISA showing an error if no report was found #40660
Boost: Fix ISA showing an error if no report was found #40660
Conversation
User might not have requested an analysis yet. That doesn't mean the UI should show an error. This restores behavior from pre-Boost 3.6.0.
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
Still unsure? Reach out in #jetpack-developers for guidance! Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works! Let's fix the error code inconsistency in wpcom instead of working around the inconsistency though.
/* | ||
* WordPress.com passes statusCode and error back from Boost Cloud. | ||
* WordPress.com ISA returns code and message. | ||
*/ | ||
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
$err_code = empty( $data['statusCode'] ) ? 'http_error' : $data['statusCode']; | ||
$message = empty( $data['error'] ) ? $default_message : $data['error']; | ||
|
||
return new \WP_Error( $err_code, $message ); | ||
if ( isset( $data['statusCode'] ) && isset( $data['error'] ) ) { | ||
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
$data_code = $data['statusCode']; | ||
$data_message = $data['error']; | ||
} elseif ( isset( $data['code'] ) && isset( $data['message'] ) ) { | ||
$data_code = $data['code']; | ||
$data_message = $data['message']; | ||
} | ||
|
||
$error_code = empty( $data_code ) ? 'http_error' : $data_code; | ||
$message = empty( $data_message ) ? $default_message : $data_message; | ||
|
||
return new \WP_Error( $error_code, $message ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should make it consistent on the wpcom part instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is going to be an easy fix. The endpoints for ISA work with the default WP functions that return code and message.
We'd have to update quite a few places to make it so it returns statusCode
and error
instead of code
and message
.
I think we might cause more harm than good.
I'm also not sure what exactly and where exactly to update it... I could remove this from the PR, since the only change is to fix the boost UI and I think the JS update fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that the change to boost core was necessary to figure out that the response is not-found
and not a generic error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment detailing why we need the band-aid I removed in afa7179.
p1734690571772729-slack-C016BBAFHHS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the band-aid back into Boost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated (d22ffed) comment explaining error normalization.
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes an error in the ISA description on freshly installed premium sites:
The reason this happens is because the UI makes a request for the
latest
report to WP.com. There's no report, and WP.com reportsnot-found
for that report. Due to a fix of a bug in a previous PR, this started showing as an error since Boost 3.6.0 was released.This changes the UI to ignore the
not-found
status from WP.com (just like it did prior to the fixing the above mentioned bug).Proposed changes:
not-found
reports showing as an error in the UI.Other information:
Jetpack product discussion
p1734518619728809-slack-C016BBAFHHS
Does this pull request change what data or activity we track or use?
no
Testing instructions:
Test that you can see an error:
Test that the error is not showing: