QueryEditor: datasource getQueryDisplayText error (#114106)

Fixes an issue where `getQueryDisplayText` throes an error and breaks the query editor.
This commit is contained in:
Kristina Demeshchik
2025-11-18 13:58:55 -05:00
committed by GitHub
parent 1458a28eee
commit bf3de07147
@@ -310,11 +310,18 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
renderCollapsedText(): string | null {
const { datasource } = this.state;
if (datasource?.getQueryDisplayText) {
return datasource.getQueryDisplayText(this.props.query);
if (!datasource || typeof datasource.getQueryDisplayText !== 'function') {
return null;
}
return null;
try {
return datasource.getQueryDisplayText(this.props.query);
} catch (error) {
// Some datasource plugins may throw errors in getQueryDisplayText
// Return null gracefully to prevent the query editor from crashing.
return null;
}
}
renderWarnings = (type: string): JSX.Element | null => {