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

Enhance error handling for UI sendRequest service #14971

Merged
merged 5 commits into from
Nov 9, 2023

Conversation

gillespi314
Copy link
Contributor

Issue #14446

  • Add option to sendRequest service for caller to receive full AxiosError object
  • Use enhanced error information to customize error message displayed by UI in case of server-side validation errors for Windows MDM config.

Checklist for submitter

  • Added/updated tests
  • Manual QA for all new/changed functionality

@gillespi314 gillespi314 requested a review from a team as a code owner November 6, 2023 19:59
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

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

Comparison is base (aa96caa) 58.85% compared to head (ba34d86) 58.81%.
Report is 40 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14971      +/-   ##
==========================================
- Coverage   58.85%   58.81%   -0.04%     
==========================================
  Files         953      954       +1     
  Lines       80237    80303      +66     
  Branches     2222     2251      +29     
==========================================
+ Hits        47220    47227       +7     
- Misses      29340    29399      +59     
  Partials     3677     3677              
Flag Coverage Δ
frontend 51.74% <19.27%> (-0.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...s/TableContainer/DataTable/IssueCell/IssueCell.tsx 80.00% <100.00%> (+5.00%) ⬆️
frontend/services/index.ts 93.33% <83.33%> (+15.55%) ⬆️
frontend/services/entities/queries.ts 0.00% <0.00%> (ø)
frontend/services/entities/config.ts 12.90% <0.00%> (-1.39%) ⬇️
frontend/interfaces/errors.ts 14.49% <14.49%> (ø)

... and 30 files with indirect coverage changes

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

renderFlash(
"error",
enable
? "Couldn't turn on Windows MDM. Please configure Fleet with a certificate and key pair first."
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, does that mean the server's message is not used? So if the copy was to be changed, it would need to be changed in both backend and frontend?

Copy link
Contributor Author

@gillespi314 gillespi314 Nov 6, 2023

Choose a reason for hiding this comment

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

As currently implement, yes, although I may have misunderstood the discussion thread. Has this message also been implemented on the backend?

Copy link
Member

Choose a reason for hiding this comment

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

It is, returned as per the "standard" error message payload returned when there's a 422 response (I'm pretty sure we do extract those kinds of server-sent error messages elsewhere in the frontend?): https://github.com/fleetdm/fleet/pull/14858/files#diff-ff669b9f96ea80679f4651e9cf45ded57d5cd939d1e4e24977eb72d37d71e8bcR733

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll tweak this a bit to extract the error message.

jacobshandling
jacobshandling previously approved these changes Nov 6, 2023
Copy link
Contributor

@jacobshandling jacobshandling left a comment

Choose a reason for hiding this comment

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

Pending resolution of @mna's considerations

@@ -12,7 +12,8 @@ const sendRequest = async (
path: string,
data?: unknown,
responseType: AxiosResponseType = "json",
timeout?: number
timeout?: number,
includeFullAxiosError?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Any particular reason for this or just to add flexibility and observability to the error handling pattern?

ghernandez345
ghernandez345 previously approved these changes Nov 7, 2023
roperzh pushed a commit that referenced this pull request Nov 9, 2023
#14446 

~~Note that the fix requires a frontend change too, so this should not
be merged before the frontend is also ready.~~ Frontend
[PR](#14971) is ready.
@gillespi314 gillespi314 merged commit e57ea7e into main Nov 9, 2023
11 checks passed
@gillespi314 gillespi314 deleted the 14446-ui-turn-on-windows-mdm-error branch November 9, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants