- Issue created by @wim leers
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
If such errors are always JSON responses, then we can update the work @balintbrews introduced in π Improve client side error handling Fixed to surface a friendlier error than this:
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Aha, for #2 we already have β¨ [PP-1] Add the ability to surface more helpful error details for display in the UI Postponed ! π
But without a structured error response from the server for the client to consume, fixing #2 is impossible.
IOW: this is a blocker for β¨ [PP-1] Add the ability to surface more helpful error details for display in the UI Postponed .
- Assigned to traviscarden
- πΊπΈUnited States effulgentsia
Wim Leers β credited effulgentsia β .
- πΊπΈUnited States traviscarden
Wim Leers β credited traviscarden β .
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Transfering relevant info + credit from β¨ [PP-1] Add the ability to surface more helpful error details for display in the UI Postponed :
Any path that can result in an exception needs to return well-formed JSON that the UI can interpret as an error message. On the backend, that probably just means creating a new exception class (if one doesn't already exist). On the front-end, it may mean no more than you telling me the JSON format you need for error popups.
One thought I had on what's proposed is that debugging info in case of error responses from the API should be logged on the server side. E.g. a PHP stack trace surfaced in the browser is a security vulnerability.
That's a good point. We already have Drupal logging in place. Now that you point it out, I'm not sure what debugging info would be both safe and helpful in the browser console. Let's start with just the UI error message. Can you tell me how I need to format my JSON error message to be displayed nicely in the UI?
β @traviscarden, #3470321-4: [PP-1] Add the ability to surface more helpful error details for display in the UI β
By the way, there's some prior art in core's jsonapi module for returning a stack trace in the json response if the site is configured to display verbose errors and the user has access to site reports.
So long as we do those two checks, it's safe. But, the question is whether in XB's case if seeing the stack trace in the browser would be helpful or not.
β @effulgentsia, #3470321-5: [PP-1] Add the ability to surface more helpful error details for display in the UI β .
- First commit to issue fork.
- Merge request !321#3470995: OpenAPI validation errors must be provided as a JSON response β (Merged) created by longwave
- Status changed to Needs review
3 months ago 1:21pm 20 September 2024 - π¬π§United Kingdom longwave UK
The implementation here:
- tells Drupal which routes return JSON format by setting the
_format
requirement - intercepts exceptions for JSON format routes that are named
experience_builder.*
- returns the exception message as a simple JSON structure
This is enough to get started on displaying nicer errors on the client. I am not sure a stack trace would be useful to the client but it might be useful to keep in the JSON data for debugging via the network inspector?
- tells Drupal which routes return JSON format by setting the
- π¬π§United Kingdom longwave UK
A screenshot of this in action, exploiting the crash in π Emptying a required value through the UI crashes the app Active before that fix is merged:
- π¬π§United Kingdom longwave UK
Simplified this further, we have precedent in XbRouteOptionsEventSubscriber for API routes already so I used that instead - no need to force
_format: json
(although perhaps we still should for correctness?) - π¬π§United Kingdom longwave UK
It turns out that EntityFormControllerTest already tests an error that should be returned in JSON format, so I reworked the test case there to expect JSON instead - that should be enough coverage to start with?
I also ported the stack trace functionality from JSON:API module with the same conditions, and the test covers that too.
- π¬π§United Kingdom longwave UK
With a one line change I've exposed the message in the UI if the preview endpoint fails:
- Assigned to longwave
- Status changed to Needs work
3 months ago 2:32pm 20 September 2024 - πΊπΈUnited States traviscarden
I can RTBC this as soon as the (trivial) requested change is made.
- Issue was unassigned.
- Status changed to Needs review
3 months ago 2:45pm 20 September 2024 - π¬π§United Kingdom longwave UK
Reverted the UI change as it's not TypeScript safe, and should be done in β¨ [PP-1] Add the ability to surface more helpful error details for display in the UI Postponed
- Status changed to RTBC
3 months ago 3:13pm 20 September 2024 - πΊπΈUnited States traviscarden
Nice. This should immediately improve the experience for everyone.
I don't seem to have the ability to actually merge the MR, so I'll mark this RTBC until I can get it.
- πΊπΈUnited States traviscarden
I've been trying to get access to merge this MR all day, and despite apparently having all the necessary permissions, I still cannot. So if someone who can merge it kindly would, that would be great. You have my approval to do so.
- First commit to issue fork.
-
hooroomoo β
committed 1e3134ff on 0.x authored by
longwave β
Issue #3470995 by longwave, traviscarden, wim leers, effulgentsia:...
-
hooroomoo β
committed 1e3134ff on 0.x authored by
longwave β
- Status changed to Fixed
3 months ago 7:33pm 20 September 2024 Automatically closed - issue fixed for 2 weeks with no activity.