Make WordPress Core

Opened 3 years ago

Closed 22 months ago

Last modified 22 months ago

#54617 closed enhancement (fixed)

Add more details when site health checks fail

Reported by: dingo_d's profile dingo_d Owned by: clorith's profile Clorith
Milestone: 6.1 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: needs-copy-review has-patch
Focuses: Cc:

Description

I encountered a notice that said:

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API call gave the following unexpected result: (401) <html> <head><title>401 Authorization Required</title></head> <body bgcolor="white"> <center><h1>401 Authorization Required</h1></center> <hr><center>nginx</center> </body> </html> .

Now, I can see that it's probably something in nginx being blocked. But I have no idea what or on what API call this error happened.

It would be awesome if this error was more like:

The REST API call gave the following unexpected result when checking the following endpoint: ...

That way I could check this endpoint, see if I'm getting any errors or not, poke around a bit.

I remember there being similar notices thrown by the site health check, that were missing debug info.

Maybe some additional debugging information would be a good idea to have as well, for developers. wp_debug_backtrace_summary() function could be used if some issue was encountered with more debugging details.

Attachments (1)

54617.JPG (32.5 KB) - added by Clorith 2 years ago.

Download all attachments as: .zip

Change History (11)

#1 @hellofromTonya
3 years ago

  • Keywords 2nd-opinion dev-feedback removed
  • Version changed from trunk to 5.2

@Clorith
2 years ago

#2 @Clorith
2 years ago

  • Milestone changed from Awaiting Review to 6.1

I think we could safely introduce the information on what endpoint was attempted here, that seems fine.

I would not want to introduce backtraces or similar, this is a screen intended for non-technical users to either resolve scenarios on their own, or get the details on where to discover how to resolve it, and a backtrace is just far too technical an element to add to the mix at that point.

I've attached 54617.JPG as an example of giving slightly more details (and I think it might make more sense to strip html, instead of just escaping it, from the response body here, looking at your example there's a lot of markup at times).

The example splits out the response from the long string, putting it on its own line wit ha clear definition in front of it of what the user is looking at, which I think will also be more useful in the long run.

#3 @dingo_d
2 years ago

This looks great. The rest endpoint gives a bit more context where to look 👍🏼

#4 @Clorith
2 years ago

  • Keywords needs-copy-review added

Adding the proposed new strings here for someone with better copy-editing skills than I to have a quick look over and give the all clear :)

The Titles have not been modified, but the responses for number 2, and 3, have both been modified to simplify them, and provide a bit more details.


  1. If no problems are detected;

Title:

The REST API is available

Body:

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.


  1. If an error is encountered;

Title:

The REST API encountered an error

Body:

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

When testing the REST API, an error was encountered;

REST API Endpoint: <URL being requested>
REST API Response: (<WP_HTTP API error code>) <WP_HTTP API error message>


  1. If an unexpected result was encountered;

Title:

The REST API encountered an unexpected result

Body:

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

When testing the REST API, an unexpected result came up;

REST API Endpoint: <URL being requested>
REST API Response: (<HTTP Response code>) <Human readable error message for the HTTP response code>

(Note: This was originally quite messy, as it would output all the markup returned, which was not very helpful)


  1. If the result was successful, but the data returned did not indicate that things are working as expected;

Title:

The REST API did not behave correctly

Body:

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API did not process the context query parameter correctly.

This ticket was mentioned in Slack in #core by clorith. View the logs.


2 years ago

This ticket was mentioned in Slack in #core by clorith. View the logs.


22 months ago

#7 @mxbclang
22 months ago

@Clorith Suggesting some minor changes to make this a bit more parseable for non-technical users (I hope!). See below and let me know if you have any questions.

  1. If no problems are detected;

Title:

The REST API is available

Body:

The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.

  1. If an error is encountered;

Title:

The REST API encountered an error

Body:

The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.
When testing the REST API, an error was encountered:
REST API Endpoint: <URL being requested>
REST API Response: (<WP_HTTP API error code>) <WP_HTTP API error message>

  1. If an unexpected result was encountered;

Title:

The REST API encountered an unexpected result

Body:

The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.
When testing the REST API, an unexpected result was returned:
REST API Endpoint: <URL being requested>
REST API Response: (<HTTP Response code>) <Human readable error message for the HTTP response code>

  1. If the result was successful, but the data returned did not indicate that things are working as expected;

Title:

The REST API isn't working as expected

Body:

The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.
The REST API did not process the context query parameter correctly.

This ticket was mentioned in PR #3276 on WordPress/wordpress-develop by Clorith.


22 months ago
#8

  • Keywords has-patch added

Updates the texts returned for the various REST API statuses, with more accurate and user-friendly details.

Trac ticket: https://core.trac.wordpress.org/ticket/54617

#9 @Clorith
22 months ago

  • Owner set to Clorith
  • Resolution set to fixed
  • Status changed from new to closed

In 54205:

Site Health: Improve the details provided by the REST API checks.

The descriptions provided whenever a REST API check failed lacked details that would help in troubleshooting any issues, most notably the actual REST API endpoint that was being tested.

Adding this vital piece of detail, along with a revamp of the error messages shown, where previously there was a risk that the markup of your website was included as an error message, improves the overall user experience, and gives more accurate details that can be looked when looking up how to fix or improve the behavior of the REST API.

Props dingo_d, shetheliving.
Fixes #54617.

Clorith commented on PR #3276:


22 months ago
#10

Committed in 45860af62545b428719d9faeb4576f8bbc281220

Note: See TracTickets for help on using tickets.