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

Error notifications can cause React child component render failure #304

Closed
andrewazores opened this issue Sep 28, 2021 · 1 comment · Fixed by #305
Closed

Error notifications can cause React child component render failure #304

andrewazores opened this issue Sep 28, 2021 · 1 comment · Fixed by #305
Assignees
Labels
bug Something isn't working

Comments

@andrewazores
Copy link
Member

I wrote a fix to return a 401 error instead of 500 when the user has inadequate permissions, but it didn't affect the white screen issue. Looking in the browser log, I see this message:

Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=Error%3A%20Unauthorized&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    React 8
    unstable_runWithPriority scheduler.production.min.js:19
    React 5
    sub AppLayout.tsx:112
    RxJS 8
    notify Notifications.tsx:65
    danger Notifications.tsx:81
    queryForTargets Targets.service.tsx:92
    RxJS 59
    checkAuth Api.service.tsx:152
    RxJS 28
    checkAuth Login.tsx:66
    handleSubmit Login.tsx:79
    handleSubmit BearerAuthForm.tsx:57
    React 10
react-dom.production.min.js:209:186
    React 5
    unstable_runWithPriority scheduler.production.min.js:19
    React 4
    unstable_runWithPriority scheduler.production.min.js:19
    React 5
    sub AppLayout.tsx:112
    RxJS 8
    notify Notifications.tsx:65
    danger Notifications.tsx:81
    queryForTargets Targets.service.tsx:92
    RxJS 59
    checkAuth Api.service.tsx:152
    RxJS 28
    checkAuth Login.tsx:66
    handleSubmit Login.tsx:79
    handleSubmit BearerAuthForm.tsx:57
    React 10

Visiting the error decoder URL gives the following message: "Objects are not valid as a React child (found: Error: Unauthorized). If you meant to render a collection of children, use an array instead."

Originally posted by @ebaron in cryostatio/cryostat#687 (comment)

@andrewazores
Copy link
Member Author

The cause for this specific issue appears to be this:

this.notifications.danger('Target List Update Failed', err)

Here, an error occurs, and the service attempts to display a notification with an error object as the message. This will fail to render - the message must be a string. Since the error format is not necessarily well-known, a simple enough solution would be to just JSON.stringify(err) to ensure that the error is serialized to a renderable form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant