Skip to content

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

chore: show worksheet even if the database not found (#15647)

ecmadao52c733a39ecc
diff --git a/backend/api/v1/worksheet_service.go b/backend/api/v1/worksheet_service.go
index 102cd2a7fd..1a6b92e09b 100644
--- a/backend/api/v1/worksheet_service.go
+++ b/backend/api/v1/worksheet_service.go
@@ -535,16 +535,16 @@ func (s *WorksheetService) convertToAPIWorksheetMessage(ctx context.Context, wor
databaseParent := ""
if worksheet.InstanceID != nil && worksheet.DatabaseName != nil {
database, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
+ ProjectID: &worksheet.ProjectID,
InstanceID: worksheet.InstanceID,
DatabaseName: worksheet.DatabaseName,
})
if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to get database: %v", err)
+ slog.Debug("failed to found database for worksheet", log.BBError(err), slog.Int("id", worksheet.UID), slog.String("instance", *worksheet.InstanceID), slog.String("database", *worksheet.DatabaseName))
}
- if database == nil {
- return nil, status.Errorf(codes.NotFound, "database %s not found", *worksheet.DatabaseName)
+ if database != nil {
+ databaseParent = common.FormatDatabase(database.InstanceID, database.DatabaseName)
}
- databaseParent = fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName)
}
visibility := v1pb.Worksheet_VISIBILITY_UNSPECIFIED
diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.ts
index fed0578264..f1972dbaae 100644
--- a/frontend/src/store/modules/v1/database.ts
+++ b/frontend/src/store/modules/v1/database.ts
@@ -241,7 +241,9 @@ export const batchGetOrFetchDatabases = async (databaseNames: string[]) => {
if (!databaseName || !isValidDatabaseName(databaseName)) {
return;
}
- return store.getOrFetchDatabaseByName(databaseName, true /* silent */);
+ return store
+ .getOrFetchDatabaseByName(databaseName, true /* silent */)
+ .catch(() => {});
})
);
};
diff --git a/frontend/src/store/modules/v1/worksheet.ts b/frontend/src/store/modules/v1/worksheet.ts
index 6c2275232d..8a3fb4a8cf 100644
--- a/frontend/src/store/modules/v1/worksheet.ts
+++ b/frontend/src/store/modules/v1/worksheet.ts
@@ -67,11 +67,15 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {
cacheByUID.invalidateEntity([uid, "BASIC"]);
}
- await Promise.all([
- projectStore.getOrFetchProjectByName(worksheet.project),
- databaseStore.getOrFetchDatabaseByName(worksheet.database),
- userStore.getOrFetchUserByIdentifier(worksheet.creator),
- ]);
+ try {
+ await Promise.all([
+ projectStore.getOrFetchProjectByName(worksheet.project),
+ databaseStore.getOrFetchDatabaseByName(worksheet.database),
+ userStore.getOrFetchUserByIdentifier(worksheet.creator),
+ ]);
+ } catch {
+ // ignore error
+ }
cacheByUID.setEntity([uid, view], worksheet);
};
const setListCache = async (worksheets: Worksheet[]) => {
diff --git a/frontend/src/views/sql-editor/EditorCommon/SheetConnectionIcon.vue b/frontend/src/views/sql-editor/EditorCommon/SheetConnectionIcon.vue
index 2b190f8cce..bef1957b66 100644
--- a/frontend/src/views/sql-editor/EditorCommon/SheetConnectionIcon.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/SheetConnectionIcon.vue
@@ -6,31 +6,28 @@
</template>
<script setup lang="ts">
-import { computedAsync } from "@vueuse/core";
import { UnlinkIcon } from "lucide-vue-next";
+import { computed } from "vue";
import { EngineIcon } from "@/components/Icon";
-import { useDatabaseV1Store } from "@/store";
-import type { SQLEditorTab } from "@/types";
-import type { Worksheet } from "@/types/proto/v1/worksheet_service";
+import { type SQLEditorTab, isValidInstanceName } from "@/types";
import { connectionForSQLEditorTab } from "@/utils";
const props = defineProps<{
- sheet?: Worksheet;
tab?: SQLEditorTab;
}>();
-const instance = computedAsync(async () => {
- const { sheet, tab } = props;
- if (sheet) {
- if (!sheet.database) return undefined;
- const database = await useDatabaseV1Store().getOrFetchDatabaseByName(
- sheet.database
- );
- return database.instanceResource;
+const instance = computed(() => {
+ const { tab } = props;
+ if (!tab) {
+ return;
}
- if (tab) {
- return connectionForSQLEditorTab(tab).instance;
+ const { instance } = connectionForSQLEditorTab(tab);
+ if (!instance) {
+ return;
}
- return undefined;
+ if (!isValidInstanceName(instance.name)) {
+ return;
+ }
+ return instance;
});
</script>