Skip to content
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

[MM-933] Updated code to display proper errors on UI #986

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

raghavaggarwal2308
Copy link
Contributor

Summary

  • Updated the backend code to return proper errors instead of empty responses for the "get-search-autocomplete-fields" and "get-search-users" API.
  • Updated UI code to display a generic error in case of "get-search-autocomplete-fields" and "get-search-users" API calls.

Screenshot

error_fetching_Data

Ticket Link

Fixes #933

1. Updated the backend code to return proper errors instead of empty response for the "get-search-autocomplete-fields" and "get-search-users" API.
2. Updated UI code to display a generic error in case of "get-search-autocomplete-fields" and "get-search-users" API calls.
@raghavaggarwal2308 raghavaggarwal2308 changed the title [MI-3635] Updated code to display proper errors on UI [MM-933] Updated code to display proper errors on UI Oct 17, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (d1e233a) 29.65% compared to head (36936a5) 29.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #986      +/-   ##
==========================================
+ Coverage   29.65%   29.66%   +0.01%     
==========================================
  Files          52       52              
  Lines        7794     7790       -4     
==========================================
  Hits         2311     2311              
+ Misses       5287     5283       -4     
  Partials      196      196              
Files Coverage Δ
server/autocomplete_search.go 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +47 to +48
}).catch((e) => {
throw new Error('Error fetching data');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are sort of "swallowing" this error here. Is the error present in e helpful to the user at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickmister I don't think the errors are helpful for the user. You can check the errors returned in this PR only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm wondering why we're returning an error from the API if we're not using it on the frontend though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickmister We want to show the error to the user in case we are unable to fetch the data. If we don't send the error from the API we won't be able to display the generic error. Please correct me if I am wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright that makes sense

}

w.Header().Set("Content-Type", "application/json")
_, err = w.Write(bb)
if err != nil {
return http.StatusInternalServerError,
errors.WithMessage(err, "failed to write response")
return http.StatusInternalServerError, errors.WithMessage(err, "failed to write response")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice we're not calling respondErr here. I think that's intentional since this error is coming from a failure to write a response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickmister We were not calling respondErr anywhere in the function. I think we should as the user will not see any data in the dropdown in this case as well. Please let me know your thoughts on this.

@mickmister mickmister merged commit 70078a0 into mattermost:master Nov 20, 2023
9 checks passed
@mickmister mickmister mentioned this pull request Dec 20, 2023
@avas27JTG avas27JTG added this to the v4.1.0 milestone Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SyntaxError: Unexpected end of JSON input
5 participants