Skip to content

Commit

Permalink
fix(dashboard): missing null check in error extra (#27845)
Browse files Browse the repository at this point in the history
(cherry picked from commit f25795c)
  • Loading branch information
justinpark authored and michael-s-molina committed Apr 3, 2024
1 parent 6ba1dfb commit 4581b46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ const mockedProps = {
};

test('should render', () => {
const { container } = render(<DatabaseErrorMessage {...mockedProps} />);
const nullExtraProps = {
...mockedProps,
error: {
...mockedProps.error,
extra: null,
},
};
const { container } = render(<DatabaseErrorMessage {...nullExtraProps} />);
expect(container).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function DatabaseErrorMessage({
error,
source = 'dashboard',
subtitle,
}: ErrorMessageComponentProps<DatabaseErrorExtra>) {
}: ErrorMessageComponentProps<DatabaseErrorExtra | null>) {
const { extra, level, message } = error;

const isVisualization = ['dashboard', 'explore'].includes(source);
Expand All @@ -47,7 +47,7 @@ function DatabaseErrorMessage({
{t('This may be triggered by:')}
<br />
{extra.issue_codes
.map<React.ReactNode>(issueCode => (
?.map<React.ReactNode>(issueCode => (
<IssueCode {...issueCode} key={issueCode.code} />
))
.reduce((prev, curr) => [prev, <br />, curr])}
Expand Down

0 comments on commit 4581b46

Please sign in to comment.