: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(endpoints): surface materialization update errors (#110753)
Jovan Sakovica34a26f15eee
diff --git a/products/endpoints/frontend/endpointLogic.test.ts b/products/endpoints/frontend/endpointLogic.test.tsnew file mode 100644index 000000000000..b374a4a52c03--- /dev/null+++ b/products/endpoints/frontend/endpointLogic.test.ts@@ -0,0 +1,42 @@+import api from 'lib/api'+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'++import { initKeaTests } from '~/test/init'+import { expectLogic } from '~/test/keaTestUtils'++import { endpointLogic } from './endpointLogic'++jest.mock('lib/api', () => ({+ __esModule: true,+ default: {+ endpoint: {+ update: jest.fn(),+ },+ },+}))++jest.mock('lib/lemon-ui/LemonToast/LemonToast', () => ({+ lemonToast: { success: jest.fn(), error: jest.fn() },+}))++describe('endpointLogic', () => {+ beforeEach(() => {+ jest.clearAllMocks()+ initKeaTests()+ })++ it('shows the API detail when an endpoint update fails', async () => {+ ;(api.endpoint.update as jest.Mock).mockRejectedValue({+ detail: 'Cannot materialize endpoint. Reason: The referenced table does not exist.',+ })+ const logic = endpointLogic()+ logic.mount()++ logic.actions.updateEndpoint('example-endpoint', { is_materialized: true })+ await expectLogic(logic).toFinishAllListeners()++ expect(lemonToast.error).toHaveBeenCalledWith(+ 'Failed to update endpoint: Cannot materialize endpoint. Reason: The referenced table does not exist.'+ )+ })+})diff --git a/products/endpoints/frontend/endpointLogic.tsx b/products/endpoints/frontend/endpointLogic.tsxindex 50bbd934aef8..f40333df1a18 100644--- a/products/endpoints/frontend/endpointLogic.tsx+++ b/products/endpoints/frontend/endpointLogic.tsx@@ -432,8 +432,7 @@ export const endpointLogic = kea<endpointLogicType>([actions.updateEndpointSuccess(response, name, options)} catch (error: any) {console.error('Failed to update endpoint:', error)- const queryError = error.attr === 'query' ? error.detail : null- actions.updateEndpointFailure(queryError)+ actions.updateEndpointFailure(error.detail || null)}},updateEndpointSuccess: ({ response, endpointName, options }) => {