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

cluster-ui: fix insights page crash #120137

Merged
merged 1 commit into from Mar 11, 2024

Conversation

laurenbarker
Copy link
Contributor

When the Schema Insights Type is unitialized, the Schema Insights tab would crash because a string method was being called on undefined. The types are all correct, but because strict mode isn't enabled, it's not considered a type error.

Now the string method is only called if the Schema Insights Type is defined.

Fixes: https://cockroachlabs.atlassian.net/browse/CC-27391

Release note (bug fix): Fixes intermittent page crash on the Schema Insights view.

@laurenbarker laurenbarker requested a review from a team as a code owner March 8, 2024 16:47
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@@ -564,7 +564,7 @@ export class Filter extends React.Component<QueryFilter, FilterState> {
}))
: [];
const schemaInsightTypeValue = schemaInsightTypeOptions.filter(option => {
return filters.schemaInsightType.split(",").includes(option.label);
return filters.schemaInsightType?.split(",").includes(option.label);
Copy link
Member

Choose a reason for hiding this comment

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

If we're changing this code anyways, can we create the array (or set) outside of the filter fn:

const selectedSchemaInsightTypes = filters.schemaInsightType?.split(",") ?? [];
const schemaInsightTypeValue = schemaInsightTypeOptions.filter(option => selectedSchemaInsightTypes.includes(option.label);
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! I went ahead and fixed all the other issues of the same type in the file since we see these errors in the console logs quite frequently.

When the Schema Insights Type is unitialized, the Schema Insights tab
would crash because a string method was being called on `undefined`. The
types are all correct, but because strict mode isn't enabled, it's not
considered a type error.

Now the string method is only called if the Schema Insights Type is
defined.

The same type issue that was fixed for `filters.schemaInsightType` was
fixed for all other filters in the same file as well.

Fixes: https://cockroachlabs.atlassian.net/browse/CC-27391

Release note (bug fix): Fixes intermittent page crash on the Schema
Insights view.
@laurenbarker
Copy link
Contributor Author

TFTR @xinhaoz!

@laurenbarker
Copy link
Contributor Author

bors r+

@laurenbarker laurenbarker added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. and removed backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Mar 11, 2024
@laurenbarker
Copy link
Contributor Author

blathers backport 23.2

@laurenbarker laurenbarker removed the backport-23.2.x Flags PRs that need to be backported to 23.2. label Mar 11, 2024
@craig
Copy link
Contributor

craig bot commented Mar 11, 2024

Build succeeded:

@craig craig bot merged commit 436fcd5 into cockroachdb:master Mar 11, 2024
16 of 19 checks passed
@laurenbarker laurenbarker deleted the insights-page-error branch March 11, 2024 17:36
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.

None yet

3 participants