Fix the display of server/API error messages in the UI

RESOLVED FIXED

Status

Tree Management
Treeherder
P2
normal
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: emorley, Assigned: emorley)

Tracking

Details

Attachments

(1 attachment)

(Assignee)

Description

2 years ago
We have ThModelErrors which provides useful errors in the case of failed requests (eg it includes the server response body and special-cases auth):
https://github.com/mozilla/treeherder/blob/master/ui/js/models/error.js

However:
(a) not everything is using it (eg persona login failures or auto-classification saving)
(b) If there is no server body, it doesn't show the HTTP status code
(c) It assumes the response will be a json object that has a 'detail' attribute (we should handle a pure text response and also gracefully handle getting a full html page load balancer style response)

We should fix this prior to the Heroku migration, since otherwise the "down for maintenance" HTTP 503 responses won't be displayed in the UI properly (eg currently login gets "Login failed: 503 SERVICE UNAVAILABLE", which doesn't include the maintenance message in the response body).
(Assignee)

Updated

2 years ago
Assignee: nobody → emorley
Summary: Consolidate UI request error handling → Fix the display of server/API error messages in the UI
Created attachment 8796210 [details] [review]
[treeherder] mozilla:fix-ui-error-messages > mozilla:master
(Assignee)

Updated

2 years ago
Attachment #8796210 - Flags: review?(cdawson)

Updated

2 years ago
Attachment #8796210 - Flags: review?(cdawson) → review+

Comment 2

2 years ago
Commits pushed to master at https://github.com/mozilla/treeherder

https://github.com/mozilla/treeherder/commit/cb7ff988ff42029c29cfb7edb3409dc96a1659a2
Bug 1290082 - Make ThModelErrors use HTTP status code if no API message

Previously if the server response wasn't valid json with a `detail`
attribute, only the generic message from the `ThModelErrors.format()`
call (eg "Unable to cancel job") would be displayed.

Now, `format()` will fall back to including the HTTP status code (and
corresponding text description of that code) too.

We intentionally don't display the server response if it's not valid
json, since in this case it's likely several hundreds lines of HTML from
the load balancer. (And users can always inspect the response manually.)

https://github.com/mozilla/treeherder/commit/7edb2350a2fa0eeec8781a43f677f641ac139e18
Bug 1290082 - Use ThModelErrors for classification and persona errors

There are still other API error cases that aren't yet using
`ThModelErrors`, however these two cases are the most important for now,
since otherwise the Heroku migration maintenance messages won't be
displayed in the UI.
(Assignee)

Updated

2 years ago
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
(Assignee)

Updated

2 years ago
Depends on: 1306760
You need to log in before you can comment on or make changes to this bug.