diff --git a/src/datasource/components/ConfigEditor.tsx b/src/datasource/components/ConfigEditor.tsx index a418e07c1..400b8b233 100644 --- a/src/datasource/components/ConfigEditor.tsx +++ b/src/datasource/components/ConfigEditor.tsx @@ -49,8 +49,8 @@ export const ConfigEditor = (props: Props) => { .then((ds) => { if (ds) { const selectedDs = getDirectDBDatasources().find((dsOption) => dsOption.id === ds.id); - setSelectedDBDatasource({ label: selectedDs.name, value: selectedDs.id }); - setCurrentDSType(selectedDs.type); + setSelectedDBDatasource({ label: selectedDs?.name, value: selectedDs?.id }); + setCurrentDSType(selectedDs?.type); onOptionsChange({ ...options, jsonData: { @@ -64,8 +64,8 @@ export const ConfigEditor = (props: Props) => { const selectedDs = getDirectDBDatasources().find( (dsOption) => dsOption.id === options.jsonData.dbConnectionDatasourceId ); - setSelectedDBDatasource({ label: selectedDs.name, value: selectedDs.id }); - setCurrentDSType(selectedDs.type); + setSelectedDBDatasource({ label: selectedDs?.name, value: selectedDs?.id }); + setCurrentDSType(selectedDs?.type); } } }, []); @@ -225,13 +225,13 @@ export const ConfigEditor = (props: Props) => {