Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

GDGT-1844 Opening a non existant transform from Data Structure folder breaks the ui (#75035)

Kamil Mielnik96dbeb455a37
diff --git a/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts b/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts
index 8afab851df5..814aec90010 100644
--- a/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/transforms/reproductions.cy.spec.ts
@@ -174,6 +174,43 @@ describe("issue UXW-3160", () => {
});
});
+describe("issue 69904", () => {
+ const TRANSFORM_TARGET_TABLE = "deleted_transform_table";
+
+ beforeEach(() => {
+ H.restore("postgres-writable");
+ cy.signInAsAdmin();
+ H.activateToken("pro-self-hosted");
+ H.updateSetting("transforms-enabled", true);
+ });
+
+ it("should not crash the app when opening table created by a deleted transform (metabase#69904)", () => {
+ H.createAndRunSqlTransform({
+ name: "Transform to delete",
+ sourceQuery: "SELECT 1 AS answer",
+ targetTable: TRANSFORM_TARGET_TABLE,
+ targetSchema: "public",
+ }).then(({ transformId }) => {
+ cy.request("DELETE", `/api/transform/${transformId}`);
+
+ H.getTableId({
+ databaseId: WRITABLE_DB_ID,
+ name: TRANSFORM_TARGET_TABLE,
+ }).then((tableId) => {
+ H.DataModel.visitDataStudio({
+ databaseId: WRITABLE_DB_ID,
+ schemaId: `${WRITABLE_DB_ID}:public`,
+ tableId,
+ });
+ });
+
+ H.DataModel.TableSection.get()
+ .findByText("Transform does not exist anymore")
+ .should("be.visible");
+ });
+ });
+});
+
describe("issue GDGT-2429", () => {
beforeEach(() => {
H.restore("postgres-writable");
diff --git a/frontend/src/metabase-types/api/table.ts b/frontend/src/metabase-types/api/table.ts
index b5b22b5f166..99775e4436f 100644
--- a/frontend/src/metabase-types/api/table.ts
+++ b/frontend/src/metabase-types/api/table.ts
@@ -76,7 +76,7 @@ export type Table = {
estimated_row_count?: number | null;
transform_id: TransformId | null; // readonly
view_count: number;
- transform?: Transform;
+ transform?: Transform | null;
collection_id: CollectionId | null;
is_published: boolean;
diff --git a/frontend/src/metabase/data-studio/data-model/components/TableSection/components/TableAttributesEditSingle.tsx b/frontend/src/metabase/data-studio/data-model/components/TableSection/components/TableAttributesEditSingle.tsx
index f611c06f9da..6e2adaa579b 100644
--- a/frontend/src/metabase/data-studio/data-model/components/TableSection/components/TableAttributesEditSingle.tsx
+++ b/frontend/src/metabase/data-studio/data-model/components/TableSection/components/TableAttributesEditSingle.tsx
@@ -187,18 +187,24 @@ export function TableAttributesEditSingle({ table, onUpdate }: Props) {
className={S.gridLabelInput}
/>
- <TransformLink table={table} />
+ {table.data_source === "metabase-transform" && (
+ <TransformLink table={table} />
+ )}
</div>
</TableSectionGroup>
);
}
function TransformLink({ table }: { table: Table }) {
const { transform } = table;
- const shouldShowTransform =
- transform !== undefined && table.data_source === "metabase-transform";
- if (!shouldShowTransform) {
- return null;
+ if (!transform) {
+ return (
+ <Box
+ c="error"
+ className={S.transformLink}
+ fz="sm"
+ >{t`Transform does not exist anymore`}</Box>
+ );
}
return (