Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(frontend): improve Position handling for unknown line/column values (#17771)

Danny Xuf8581c6c722d
diff --git a/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
index 43f5b15655..77da5cc1f9 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
+++ b/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
@@ -16,20 +16,27 @@ export const useSQLAdviceMarkers = (
if (isCreating.value) {
if (!advices) return [];
if (!advices.value) return [];
- return advices.value.map<AdviceOption>((advice) => {
- const line = advice.startPosition?.line ?? 0;
- const column = advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
- const code = advice.code;
- return {
- severity: advice.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
- message: advice.content,
- source: `${advice.title} (${code}) L${line}:C${column}`,
- startLineNumber: line,
- endLineNumber: line,
- startColumn: column,
- endColumn: column,
- };
- });
+ return advices.value
+ .filter((advice) => {
+ // Filter out advices without valid position (line 0 means unknown)
+ const line = advice.startPosition?.line ?? 0;
+ return line > 0;
+ })
+ .map<AdviceOption>((advice) => {
+ const line = advice.startPosition!.line;
+ const column = advice.startPosition!.column || 1;
+ const code = advice.code;
+ return {
+ severity:
+ advice.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
+ message: advice.content,
+ source: `${advice.title} (${code}) L${line}:C${column}`,
+ startLineNumber: line,
+ endLineNumber: line,
+ startColumn: column,
+ endColumn: column,
+ };
+ });
} else {
const { selectedTask, getPlanCheckRunsForTask } = context;
const planCheckRunList = getPlanCheckRunsForTask(selectedTask.value);
@@ -66,12 +73,18 @@ const getLatestAdviceOptions = (planCheckRunList: PlanCheckRun[]) => {
result.report?.case === "sqlReviewReport" &&
result.report.value.startPosition !== undefined
)
- .map<AdviceOption>((result) => {
+ .filter((result) => {
+ // Filter out results without valid position (line 0 means unknown)
const sqlReviewReport =
result.report?.case === "sqlReviewReport" ? result.report.value : null;
const line = sqlReviewReport?.startPosition?.line ?? 0;
- const column =
- sqlReviewReport?.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
+ return line > 0;
+ })
+ .map<AdviceOption>((result) => {
+ const sqlReviewReport =
+ result.report?.case === "sqlReviewReport" ? result.report.value : null;
+ const line = sqlReviewReport!.startPosition!.line;
+ const column = sqlReviewReport!.startPosition!.column || 1;
const code = result.code;
return {
severity: result.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
diff --git a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
index 8cf495ac1c..30b8e6956a 100644
--- a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
+++ b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
@@ -15,20 +15,27 @@ export const useSQLAdviceMarkers = (
if (isCreating.value) {
if (!advices) return [];
if (!advices.value) return [];
- return advices.value.map<AdviceOption>((advice) => {
- const line = advice.startPosition?.line ?? 0;
- const column = advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
- const code = advice.code;
- return {
- severity: advice.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
- message: advice.content,
- source: `${advice.title} (${code}) L${line}:C${column}`,
- startLineNumber: line,
- endLineNumber: line,
- startColumn: column,
- endColumn: column,
- };
- });
+ return advices.value
+ .filter((advice) => {
+ // Filter out advices without valid position (line 0 means unknown)
+ const line = advice.startPosition?.line ?? 0;
+ return line > 0;
+ })
+ .map<AdviceOption>((advice) => {
+ const line = advice.startPosition!.line;
+ const column = advice.startPosition!.column || 1;
+ const code = advice.code;
+ return {
+ severity:
+ advice.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
+ message: advice.content,
+ source: `${advice.title} (${code}) L${line}:C${column}`,
+ startLineNumber: line,
+ endLineNumber: line,
+ startColumn: column,
+ endColumn: column,
+ };
+ });
} else {
if (!planCheckRuns) return [];
if (!planCheckRuns.value) return [];
@@ -64,12 +71,18 @@ const getLatestAdviceOptions = (planCheckRuns: PlanCheckRun[]) => {
result.report.case === "sqlReviewReport" &&
result.report.value.startPosition !== undefined
)
- .map<AdviceOption>((result) => {
+ .filter((result) => {
+ // Filter out results without valid position (line 0 means unknown)
const sqlReviewReport =
result.report.case === "sqlReviewReport" ? result.report.value : null;
const line = sqlReviewReport?.startPosition?.line ?? 0;
- const column =
- sqlReviewReport?.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
+ return line > 0;
+ })
+ .map<AdviceOption>((result) => {
+ const sqlReviewReport =
+ result.report.case === "sqlReviewReport" ? result.report.value : null;
+ const line = sqlReviewReport!.startPosition!.line;
+ const column = sqlReviewReport!.startPosition!.column || 1;
const code = result.code;
return {
severity: result.status === Advice_Level.ERROR ? "ERROR" : "WARNING",
diff --git a/frontend/src/components/Plan/components/common/CheckResultItem.vue b/frontend/src/components/Plan/components/common/CheckResultItem.vue
index 34ffbbdd6e..28a3e49b4f 100644
--- a/frontend/src/components/Plan/components/common/CheckResultItem.vue
+++ b/frontend/src/components/Plan/components/common/CheckResultItem.vue
@@ -13,8 +13,17 @@
<div v-if="content" class="text-sm text-control">
{{ content }}
</div>
- <div v-if="position" class="text-sm mt-1 text-control-light">
- Line {{ position.line }}, Column {{ position.column }}
+ <div
+ v-if="position && (position.line > 0 || position.column > 0)"
+ class="text-sm mt-1 text-control-light"
+ >
+ <template v-if="position.line > 0">
+ {{ $t("common.line") }} {{ position.line }}
+ </template>
+ <template v-if="position.line > 0 && position.column > 0">, </template>
+ <template v-if="position.column > 0">
+ {{ $t("common.column") }} {{ position.column }}
+ </template>
</div>
<div
v-if="affectedRows !== undefined"
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 3bb650429a..224ad37d8e 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -245,7 +245,9 @@
"double-comfirm": "To confirm deletion, please type: {name}",
"notification": "Successfully delete the resource '{name}'."
},
- "collapse": "Collapse"
+ "collapse": "Collapse",
+ "line": "Line",
+ "column": "Column"
},
"error-page": {
"go-back-home": "Go back home"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 4aa3987547..b8f94f42ea 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -245,7 +245,9 @@
"double-comfirm": "Para confirmar la eliminación, escriba: {name}",
"notification": "Se eliminó exitosamente el recurso '{name}'."
},
- "collapse": "Colapsar"
+ "collapse": "Colapsar",
+ "line": "Línea",
+ "column": "Columna"
},
"error-page": {
"go-back-home": "Volver al inicio"
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 31525d695c..8119f64602 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -245,7 +245,9 @@
"double-comfirm": "削除を確認するには、{name} と入力してください。",
"notification": "リソース '{name}' を正常に削除しました。"
},
- "collapse": "閉じる"
+ "collapse": "閉じる",
+ "line": "行",
+ "column": "列"
},
"error-page": {
"go-back-home": "ホームページに戻る"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index e735443a04..d63609c77b 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -245,7 +245,9 @@
"double-comfirm": "Để xác nhận xóa, vui lòng nhập: {name}",
"notification": "Xóa thành công tài nguyên '{name}'."
},
- "collapse": "Sụp đổ"
+ "collapse": "Sụp đổ",
+ "line": "Dòng",
+ "column": "Cột"
},
"error-page": {
"go-back-home": "Về trang chủ"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 9ea9ce4151..635e7a77c8 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -245,7 +245,9 @@
"double-comfirm": "要确认删除,请输入:{name}",
"notification": "成功删除资源“{name}”。"
},
- "collapse": "收起"
+ "collapse": "收起",
+ "line": "行",
+ "column": "列"
},
"error-page": {
"go-back-home": "回到主页"
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
index 70ffcf1119..9d261dedfc 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
@@ -15,7 +15,13 @@
</div>
<div class="flex items-center gap-1">
<span>{{ title }}</span>
- <NButton size="tiny" quaternary type="primary" @click="doScroll">
+ <NButton
+ v-if="hasValidPosition"
+ size="tiny"
+ quaternary
+ type="primary"
+ @click="doScroll"
+ >
L{{ position.startLine }}:C{{ position.startColumn }}
</NButton>
</div>
@@ -50,16 +56,22 @@ const title = computed(() => {
return parts.join(" ");
});
+const hasValidPosition = computed(() => {
+ const { advice } = props;
+ // Position with line 0 means unknown position
+ return (advice.startPosition?.line ?? 0) > 0;
+});
+
const position = computed(() => {
const { advice, executeParams } = props;
const [startLine, startColumn] = positionWithOffset(
- advice.startPosition?.line ?? 0,
- advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER,
+ advice.startPosition?.line ?? 1,
+ advice.startPosition?.column || 1,
executeParams?.selection
);
const [endLine, endColumn] = positionWithOffset(
- advice.endPosition?.line ?? 0,
- advice.endPosition?.column ?? Number.MAX_SAFE_INTEGER,
+ advice.endPosition?.line ?? startLine,
+ advice.endPosition?.column || startColumn,
executeParams?.selection
);
return {