-
Notifications
You must be signed in to change notification settings - Fork 34
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
API Error Handling Overhaul #1547
API Error Handling Overhaul #1547
Conversation
…ses in API, adds global error handler
… update errors to include error title
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.
This is really great work. I only noticed a few very small things that need fixing, and one behavior associated with the user_get
query that may need more investigation:
In the admin panel, copying a widget from the user panel causes the hash to update to the new instance ID, which needs to be corrected anyhow, but it appears that feeding a bad value to the user_get
query (as this behavior does) causes a repeating 500 error from the server. This is different from the previous implementation, which would simply respond with an empty value and not repeat the request.
Edit: Presumably this is related to the user_get
issues you described elsewhere, but while those were gated or handled, there may be additional calls being made to that endpoint that aren't yet properly updated.
Actually maybe we just merge #1537 into the dev branch first and then this branch incorporates the upstream changes (there shouldn't be much overlap) |
…e,checks to make sure inst exists before doing a copy in the case of a deleted instance
Great catch! The 500 error seemed to be coming from an uninitialized I also fixed the issue with the copy success handler setting the hash to the new instance ID and added an optimistic update to add the new instance to the user's managed instances. If you still get the 500 error, please let me know. |
Updated to point to 10.2.0. I can give this a final review but there appears to be a number of merge conflicts that require resolution first. |
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.
A couple endpoints are throwing errors in certain situations that make sense but have been causing issues on the front end. Two I've found so far:
widget_instance_edit_perms_verify
, called when selecting a widget in My Widgets, will return a401
if the user has insufficient edit perms - including View Scores access. React Query will continue to retry this request indefinitely, eventually erroring out the selected instance component with thePermission Denied: Failed to retrieve widget.
message.- When saving a newly created instance in the creator for the first time,
widget_instance_save
is called followed byquestion_set_get
. However,question_set_get
is not properly called, instead sending a pair ofnulls
for arguments. This call was probably unintended to begin with, but with the update the server responds with403
and react query again enters an indefinite retry loop.
With additional testing, I haven't found any other error states that cause issues on the front-end, so that's all looking great. The 403 error associated with Really the only actual problem is the 401 associated with |
Excellent catch! That function should probably not be returning an error in the first place, since its intended function is to return true/false for whether the user has edit permissions. I also noticed that users with View Scores access can update widgets in the creator. I could not think of a specific use case where this should be possible, so I've limited the
Just needed to pull dev/10.2.0, as it seems you already changed it to |
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.
This is still a big, scary PR, but as best I can tell, everything is working as intended. Committing to the 10.2 dev branch for final testing.
This PR aims to solve how errors are both sent from FuelPHP's core and handled by the front-end (#1526)
Changes
Msg
objectspost_call
andget_call
infuel/app/classes/controller/api.php
are responsible for handling responses for api calls. These will now recursively search for a 'status' field in the called function result and set that as the response status rather than an erroneous 200.api.js
. This essentially checks the status code if the response returns not OK and throws an error for individual error handlers to catch. This handler accounts for the variety of responses that can be sent from the back-end. For example:Response
class rather than theMsg
class, the error will be stored in thebody
field and must be parsed as JSON.fetch
calls to theapi/json/___
route to usefetchGet
which automatically configures the POST options and invokes the global error handler.user_get
. Theuser_get
function returns a 403 error if the user is not logged in. A non-logged in user would then get spammed with 403's in the console. Instead of changinguser_get
, which needs to return 403 in some situations, I addedapiAuthorVerify
to gate this API call.Msg::no_login()
responses are only sent ifverify_session
has been called, which will logout the user and clear the session date.Additional Findings
React Query has the option of setting a global error handler when initializing the QueryCache. This is only called if
onError
is not defined in the API call.Potential issues