Skip to content

Commit 593c1e1

Browse files
committed
fix: prevent undefined column access in SQL result viewer
1 parent 1f00f67 commit 593c1e1

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

webapp/packages/core-sdk/src/ServerInternalError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export class ServerInternalError extends DetailsError implements ServerError {
2828
}
2929

3030
override hasDetails(): boolean {
31-
return this.stack !== undefined && this.stack.length > 0 && this.errorType !== ServerErrorType.QUOTE_EXCEEDED;
31+
return this.stack !== undefined && (this.stack?.length ?? 0) > 0 && this.errorType !== ServerErrorType.QUOTE_EXCEEDED;
3232
}
3333
}

webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class ResultSetFormatAction
129129
}
130130

131131
getHeaders(): string[] {
132-
return this.view.columns.map(column => column.name!).filter(name => name !== undefined);
132+
return this.view.columns.map(column => column?.name).filter((name): name is string => name !== undefined && name !== null);
133133
}
134134

135135
getLongestCells(column?: IResultSetColumnKey, offset = 0, count?: number): string[] {

webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetViewAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ResultSetViewAction extends DatabaseDataAction<any, IDatabaseResult
3939
}
4040

4141
get columns(): SqlResultColumn[] {
42-
return this.columnsOrder.map(i => this.data.columns[i]!);
42+
return this.columnsOrder.map(i => this.data.columns[i]).filter(column => column !== undefined);
4343
}
4444

4545
private columnsOrder: number[] = [];

webapp/packages/plugin-data-viewer/src/TableViewer/TableError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const TableError = observer<Props>(function TableError({ model, loading,
160160
if (isSqlContextError) {
161161
handleReopenEditor();
162162
}
163-
}, [error.message, handleReopenEditor, model.source.error, errorInfo]);
163+
}, [error.message, handleReopenEditor, model.source.error, errorInfo, error.errorCode]);
164164

165165
return (
166166
<div

0 commit comments

Comments
 (0)