fix(bi): guard empty data array in EditorChartSql before destructuring - #2164
Conversation
|
This guard prevents destructuring an empty result, but the PR is not ready to merge because it leaves stale chart state behind. If a successful SELECT populates metadata and the next statement returns no rows (for example DDL/DML), the early return preserves the previous Please explicitly clear or replace the previous metadata while preserving the current execution's database context. Add an automated sequence test for non-empty result followed by empty result, plus an initially empty result, and rebase onto the latest |
openai0229
left a comment
There was a problem hiding this comment.
The empty-result guard still leaves stale metadata from the previous execution, and the required execution-sequence tests are missing. The current head does not address the detailed review comment already posted, so this remains blocked pending an updated commit and re-review.
onExecuteSQLCallback returned early when data was empty, preserving the previous execution's metaData/databaseInfo. Now explicitly clears metaData (empty dataList/headerList) while preserving the current execution's database context. Prevents displaying information from the wrong execution. Fixes OtterMind#2162 Co-Authored-By: Claude <noreply@anthropic.com>
271b029 to
caf9b38
Compare
|
Rebased onto latest main. Fixed the stale-metadata issue: when data is empty, the callback now explicitly clears metaData (empty dataList/headerList) while preserving the current execution's databaseInfo. This prevents displaying chart data from a previous execution. if (!data.length) {
setDatabaseInfoAndMetaData({
databaseInfo: { ... }, // current execution context
metaData: { dataList: [], headerList: [] }, // cleared
});
return;
}tsc + eslint clean. |
|
Blocking on the current head: the real path in Please add an actual handler/component sequence test for non-empty data followed by empty data, asserting that stale metadata is cleared and the current database context is preserved, plus initially empty and normal non-empty cases. |
openai0229
left a comment
There was a problem hiding this comment.
Verified the empty-data guard, targeted tests, lint, YAML validation, diff checks, and the full Community build. Required checks are passing on the current head.
Related issue
Closes #2162
Summary
EditorChartSql.onExecuteSQLCallback destructured data[0] without guarding the empty case. Running a non-result SQL statement (DDL/INSERT/UPDATE) in the BI chart SQL editor yields data = [], so data[0] is undefined and the destructure throws. Added if (!data.length) return; before the destructure.
Verification
Contributor declaration
AI assistance: The fix, verification, and PR description were produced with Claude Code assistance.