-
Notifications
You must be signed in to change notification settings - Fork 846
Simplify error notices for broken connections #16655
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
Conversation
|
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16655 Scheduled Jetpack release: September 1, 2020. |
fgiannar
left a comment
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.
Hey @leogermani ,
Nice work!
Tested this and can verify that I am able to see a no_valid_token error in XML-RPC errors, but it appears under Current Unverified Errors section instead.
The error notice and corresponding CTA appeared as expected.
Finally, a small code related suggestion: Do you believe it would make sense to add an error-handling interface, so that all error handler classes implement a contract for the admin_notice method and possibly a message property related getter/setter?
|
Thanks @fgiannar
Actually it appears on both Unverified and Verified sections. If you saw the error notices, I trust it was there.
Good
Yes, it definitely makes sense to have an interface. It would be a very generic interface though, because, in theory, each error handler can perform very different actions. Not all of them would necessarily display error on admin notice. I didn't create it yet because I'm avoiding premature abstraction... While in theory we can have many different types of error handlers, in practice, right now, we only have 2 that are actually identical... they could be the same. They only trigger different actions and filters to allow third party users (also theoretical) to act on these errors. So I'm actually tending to ask if any abstraction there is worth at this point, and if we should just have one simple method or class that adds the error to the admin notice hook. What do you think? (I'm actually waiting the partial reconnect PR to be merge to make Jetpack plugin use these hooks and customize the error messages, with a button to take the user straight to the reconnect flow.) |
The only thing that troubles me here is that while testing, I only managed to see it under the Unverified section, which could be inconsistent with the fact that it is displayed as an error to the users (I was under the impression that we only show Verified)
Having a simple method or class that adds the error to the admin notice hook sounds reasonable. |
9655dba to
6d1f30d
Compare
|
|
||
| $errors[] = array( | ||
| 'code' => 'invalid_blog_token', | ||
| 'message' => __( 'Your connection with WordPress.com seems to be broken. If you\'re experiencing issues, please try reconnecting.', 'jetpack' ), |
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 duplicated error message here is intentional.
Leaving it separated from the filter in the method above allows Jetpack plugin to have full control over it's Dashboard. If a plugin filters the message and modifies or disables it, it won't affect the Jetpack plugin.
|
@fgiannar I've refactored the code and kept it simpler. We don't need all that abstraction right now. I updated the PR description with some additional info. I also added a page in the documentation explaining how to customize or disable the error messages :) |
fgiannar
left a comment
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.
@leogermani
Tested this using the instructions and noticed the following weird behaviour:
The first time I invalidate the user token, I can see the XML-RPC error and also the error notice in the Dashboard.
After restoring my connection, if I try to repeat the above process, I don't see the error at all.
The same happens when I remove all user related tokens and set up the connection from the admin UI.
I reproduced this both in my local env and a JN site.
Could you check and let me know if you can reproduce this as well?
| public function jetpack_react_dashboard_error( $errors ) { | ||
|
|
||
| $errors[] = array( | ||
| 'code' => 'invalid_blog_token', |
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.
Hi @leogermani ,
Returning a blog token specific error code (invalid_blog_token) in the (now) generic error handler confuses me a bit. Could you please elaborate on this?
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.
Yeah, this is wrong! Nice catch
This is expected because we have the gates in place making sure we just run all the verification process once in a while to avoid overflows. On the plugin side you can easily disable this by setting On wpcom side it's more tricky, but here I explain how to do it: D47732-code (you'd have to sandbox You can also only disable the gate on the plugin. The error will appear as Unverified. You can then click the "Verify error (via api)" button and manually verify it. |
fgiannar
left a comment
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.
Awesome, thanks for adding a generic error code and pointing out to me how to disable the gate!
LGTM
|
@kraftbj @jeherve This PR is ready to merge but wanted to get your ok on something. On this PR I'm removing some classes and filters added in 8.7 that I'm sure no one is using (considering woocommerce payments as our only client right now). Since we had backward compatibility issues before, and this should most likely trigger our checks for removing methods and filters, just wanted to give you a heads up that this should look clean and safe. |
Yeah, this should be fine. 👍 |
* master: (23 commits) Premium Blocks: set blocks availability (#16898) Compat Package: Fix method declaration compatibility (#16900) Jetpack Dashboard: More meaningful error notices. (#16883) Connection REST API: Unit test for the `remote_authorize` request. (#16879) use blog token to request jetpack.updateBlog (#16698) Improve Story block media loading (#16663) Simplify error notices for broken connections (#16655) Use new heartbeat package (#16285) wrap-paid-block: remove component. deprecated. (#16895) Social Previews: improve preview description handling (#16889) Stats module use blog token (#16727) Form Block: add a new Consent Field, a new Newsletter setting, and a new newsletter variation (#16808) AAG: Backup card, fall back to VP content in case of /rewind API error. (#16867) Donations: Fix dependencies (#16892) Creative Mail: update option to lowercase (#16861) Premium Blocks: Implement the new design (#16611) Requests to Stats CSV use the blog token (#16716) Update spacing around sharing buttons to avoid no bottom margin below the customize link. (#16811) Jetpack SSO: Cleaning up the `requestNonce` API request. (#16830) Donations: Update plans when currency changes (#16844) ...
* add handler class for user tokens errors * refactor and simplify xmlrpc error notices * add docs to error messages * change error code to a generic code
#16194 introduced the ability for Jetpack to identify, confirm and handle XML-RPC errors. It also introduced admin notices to display such errors to users.
Up until now we were only displaying errors for Blog token issues. This PR adds error messages for user tokens errors too.
Refactor
This PR also simplifies the code that was displaying the errors. At first, there was this idea of having an abstraction that would allow us to treat each error code differently, having a class to handle each one of them.
However, this abstraction was in place to handle theoretical situations while, in practice, we were simply displaying the same generic error message in all case. Therefore I decided to get rid of the abstraction for now and keep it simple. When needed, it's easy to add a per error code handling there.
Note: I think it's completely safe to just remove the "blog token error handling" class and all the hooks introduced in 8.7 because they have not been used anywhere or by any other plugin using the connection package.
Changes proposed in this Pull Request:
Jetpack product discussion
p1HpG7-9q9-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Proposed changelog entry for your changes: