Post blocked on forum: optimize 418 error or 502 Bad Gateway popup

When a post is blocked on the forum, a popup displays a 418 error or a 502 Bad Gateway message. This message is not very accurate. Where on the forum can this prompt be optimized to provide users with more detailed information?

If the user goes to the browser DevTools (right click > Inspect > Console), an error message is usually logged there. Also, in /logs (visible to Admins).

Is there a way to modify this error message? For example, could the message in this popup be changed to ‘Network/Gateway Error’?

This could be a bigger underlying issue. Errors like these are not so common.

I think I found where this message comes from.

When Discourse cannot find a structured error message in the response, it falls back to the HTTP status code and statusText:

if (!parsedError) {
  if (error.status && error.status >= 400) {
    parsedError = error.status + " " + error.statusText;
  }
}

Discourse source: HTTP error fallback.[1]

This means 502 Bad Gateway is not a normal Site Text entry. It is created from the HTTP response status and status text.

The resulting message is then passed to the Discourse alert dialog here.[2]

Discourse already uses translated strings when the server returns an error_key or another structured error. For a raw 502 response, however, it reaches the fallback above.

A plugin could replace the message before displaying its own error dialog, but I do not see a public Plugin API hook for globally changing this fallback. A core change or a new plugin API hook would probably be needed to make these HTTP fallback messages globally customisable/translatable.


  1. ↩︎

  2. ↩︎

1 Like