Skip to content

Commit

Permalink
fix(dashboard): missing null check in error extra (apache#27845)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark authored and EandrewJones committed Apr 5, 2024
1 parent f3ae28c commit 6b67a0d
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 @@ -56,7 +56,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 6b67a0d

Please sign in to comment.