:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-modeling): show a deleted state for models deleted elsewhere (#118679)
Jovan Sakovicc58dbfa6eeb7
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex bee1a88e03db..fb5c6bf4030a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7306,6 +7306,10 @@ snapshots:hash: v1.k794b7964.1a4ce304197dd14d4151ca1083e7ae7039f9908200c34f7378465025b79d7e08.94Li-jYAcO0uRnZLtl2_PHZpM-CXBrx24-RLOofaY_Eproducts-data-modeling-models-overview--partial-last-page--light:hash: v1.k794b7964.0a510efc77afae6a02c52831583c4c38870a6e9c1a1dcd78c2905ff05933c085.KSDQ61iPt91mJjAozciHJ7_p5ed-dd3IkN5KPYxR204+ products-data-modeling-node-detail-scene--deleted-model--dark:+ hash: v1.k794b7964.bf008eaa19295f4131e58d639e52c574e724973ac897a20d95c905206ccfe333.8CL_nCzrTvLfheyYXNeMHjX8MI8t_lazxmw_8FtPLu4+ products-data-modeling-node-detail-scene--deleted-model--light:+ hash: v1.k794b7964.d1862e22a973b0fb2725b4b6d613eb0ddbe2074d54d20b4dbb85eb5193a994b6.0uti-ZtW-QCeFNNJ3XmHjC7NRpp3dO35TR3L3v9_Zw0products-data-modeling-node-detail-scene--materialized-view--dark:hash: v1.k794b7964.9c8663e101f08c4bd2578b787402053a1bd7e930f06fad0ee6f5f1d728b0b14c.hV26Y05ssUiKJQPOBYVX6EXXkVSkd9rCOQvnA3PRPBYproducts-data-modeling-node-detail-scene--materialized-view--light:diff --git a/products/data_modeling/frontend/nodeDetail/NodeDetailScene.stories.tsx b/products/data_modeling/frontend/nodeDetail/NodeDetailScene.stories.tsxindex 7cba241f8356..c8bd3bb3940c 100644--- a/products/data_modeling/frontend/nodeDetail/NodeDetailScene.stories.tsx+++ b/products/data_modeling/frontend/nodeDetail/NodeDetailScene.stories.tsx@@ -368,3 +368,16 @@ export const NarrowSuspendedWithRunHistory: Story = {...SuspendedWithRunHistory,decorators: NarrowView.decorators,}++export const DeletedModel: Story = {+ parameters: {+ msw: {+ mocks: {+ get: {+ '/api/environments/:team_id/data_modeling_nodes/:id/': () => [200, node],+ '/api/environments/:team_id/warehouse_saved_queries/:id/': () => [404, { detail: 'Not found.' }],+ },+ },+ },+ },+}diff --git a/products/data_modeling/frontend/nodeDetail/NodeDetailScene.tsx b/products/data_modeling/frontend/nodeDetail/NodeDetailScene.tsxindex 07db30ffad74..8f003d55326b 100644--- a/products/data_modeling/frontend/nodeDetail/NodeDetailScene.tsx+++ b/products/data_modeling/frontend/nodeDetail/NodeDetailScene.tsx@@ -6,6 +6,7 @@ import { AccessDenied } from 'lib/components/AccessDenied'import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'import { NotFound } from 'lib/components/NotFound'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'+import { Link } from 'lib/lemon-ui/Link'import { userHasAccess } from 'lib/utils/accessControlUtils'import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -58,6 +59,7 @@ export function NodeDetailScene({ id }: NodeDetailSceneLogicProps): JSX.Elementconst {node,savedQuery,+ savedQueryDeleted,savedQueryLoading,nodeLoading,availableTabs,@@ -87,6 +89,19 @@ export function NodeDetailScene({ id }: NodeDetailSceneLogicProps): JSX.Elementreturn <NotFound object="model" />}+ if (savedQueryDeleted) {+ return (+ <NotFound+ object="model"+ caption={+ <>+ This model was deleted. Go back to <Link to={urls.models()}>Models</Link>.+ </>+ }+ />+ )+ }+const savedQueryId = node.saved_query_idconst tabPanel = (tab: NodeDetailSceneTab): JSX.Element => {diff --git a/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.test.ts b/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.test.tsindex d8badf570512..0be001352d49 100644--- a/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.test.ts+++ b/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.test.ts@@ -377,6 +377,24 @@ describe('nodeDetailSceneLogic', () => {expect(logic.values.effectiveTab).toEqual('materialization')})+ it('marks the saved query deleted instead of failing when it returns 404', async () => {+ useMocks({+ get: {+ '/api/environments/:team_id/data_modeling_nodes/lineage/': { nodes: [], edges: [] },+ '/api/environments/:team_id/data_modeling_nodes/:id/': () => [200, node],+ '/api/environments/:team_id/warehouse_saved_queries/:id/': () => [404, { detail: 'Not found.' }],+ },+ })++ await mountScene(urls.nodeDetail(NODE_ID))++ await expectLogic(logic)+ .toDispatchActions(['loadSavedQuerySuccess'])+ .toNotHaveDispatchedActions(['loadSavedQueryFailure'])+ expect(logic.values.savedQueryDeleted).toBe(true)+ expect(logic.values.savedQueryError).toBe(false)+ })+// A failed saved-query request leaves the scene rendering with nothing to read is_materialized// from. Reading that absence as "not materialized" would open a matview on Query and print// "Materialization: Off" under its own Materialized view tag.diff --git a/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.ts b/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.tsindex e3a7f41e9c10..671339a584f7 100644--- a/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.ts+++ b/products/data_modeling/frontend/nodeDetail/nodeDetailSceneLogic.ts@@ -95,6 +95,7 @@ export interface nodeDetailSceneLogicValues {postHogSubjectError: booleanpostHogSubjectLoading: booleansavedQuery: DataWarehouseSavedQuery | null+ savedQueryDeleted: booleansavedQueryError: booleansavedQueryLoading: booleansavedQuerySettled: boolean@@ -176,10 +177,10 @@ export interface nodeDetailSceneLogicActions {errorObject?: any}loadNodeSuccess: (- node: DataModelingNode,+ node: DataModelingNode | null,payload?: any) => {- node: DataModelingNode+ node: DataModelingNode | nullpayload?: any}loadPostHogSubject: () => any@@ -235,6 +236,9 @@ export interface nodeDetailSceneLogicActions {} | nullpayload?: any}+ markSavedQueryDeleted: () => {+ value: true+ }openLineageModal: () => {value: true}@@ -326,6 +330,7 @@ export const nodeDetailSceneLogic = kea<nodeDetailSceneLogicType>([closeLineageModal: true,lineageNodeDragStopped: (nodeId: string, position: XYPosition) => ({ nodeId, position }),resetLineageNodePositions: true,+ markSavedQueryDeleted: true,}),reducers({// What the address bar asks for. Tab links navigate, so nothing else may write this.@@ -350,6 +355,13 @@ export const nodeDetailSceneLogic = kea<nodeDetailSceneLogicType>([loadSavedQueryFailure: () => true,},],+ savedQueryDeleted: [+ false,+ {+ loadSavedQuery: () => false,+ markSavedQueryDeleted: () => true,+ },+ ],savedQueryError: [false,{@@ -413,16 +425,24 @@ export const nodeDetailSceneLogic = kea<nodeDetailSceneLogicType>([},],}),- loaders(({ props, values }) => ({+ loaders(({ actions, props, values }) => ({node: {__default: null as DataModelingNode | null,loadNode: async () => {const lookup = router.values.searchParams.lookup- return (await dataModelingNodesRetrieve(- String(values.currentProjectId),- props.id,- isNodeLookup(lookup) ? { lookup } : undefined- )) as DataModelingNode+ try {+ return (await dataModelingNodesRetrieve(+ String(values.currentProjectId),+ props.id,+ isNodeLookup(lookup) ? { lookup } : undefined+ )) as DataModelingNode+ } catch (error: any) {+ // The scene renders its not-found state for a null node, so a 404 needs no toast.+ if (error?.status === 404) {+ return null+ }+ throw error+ }},updateNodeDescription: async ({ description }) => {const updated = await api.dataModelingNodes.update(props.id, { description })@@ -436,7 +456,15 @@ export const nodeDetailSceneLogic = kea<nodeDetailSceneLogicType>([if (!node?.saved_query_id) {return null}- return await api.dataWarehouseSavedQueries.get(node.saved_query_id)+ try {+ return await api.dataWarehouseSavedQueries.get(node.saved_query_id)+ } catch (error: any) {+ if (error?.status === 404) {+ actions.markSavedQueryDeleted()+ return null+ }+ throw error+ }},},lineageGraph: {