: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(dashboards): surface failed tile duplicates instead of faking success (#86621)
posthog[bot]00da537041f2
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.tsindex dc498c03d392..f2929e4f2128 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts@@ -9,6 +9,7 @@ import * as dashboardWidgetUtils from '@posthog/products-dashboards/frontend/utiimport { DASHBOARD_WIDGET_FETCH_ERROR_MESSAGE } from '@posthog/products-dashboards/frontend/widgets/constants'import api from 'lib/api'+import { ApiError } from 'lib/api-error'import { FEATURE_FLAGS } from 'lib/constants'import { dayjs, now } from 'lib/dayjs'import * as featureFlagLib from 'lib/logic/featureFlagLogic'@@ -3083,6 +3084,27 @@ describe('dashboardLogic', () => {})})+ it('surfaces a failed tile duplicate instead of resolving it as a success', async () => {+ silenceKeaLoadersErrors()+ const errorToast = jest.spyOn(lemonToast, 'error')+ jest.spyOn(api, 'update').mockRejectedValueOnce(+ new ApiError('forbidden', 403, undefined, { detail: 'You do not have permission' })+ )++ logic = dashboardLogic({ id: 5 })+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ await expectLogic(logic, () => {+ logic.actions.duplicateTile(WIDGET_TILE)+ })+ .toDispatchActions(['duplicateTileFailure'])+ .toFinishAllListeners()++ expect(errorToast).toHaveBeenCalledWith('You do not have permission')+ resumeKeaLoadersErrors()+ })+it('addWidgetTiles refreshes newly created widget tiles', async () => {const addedTile = {id: 99,diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsxindex f46b05944fd5..a8d760717a2b 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx@@ -1628,8 +1628,10 @@ export const dashboardLogic = kea<dashboardLogicType>([)return getQueryBasedDashboard(dashboard)} catch (e) {- lemonToast.error('Could not duplicate tile: ' + String(e))- return values.dashboard+ // Re-throw so duplicateTileFailure fires. Swallowing the error resolved it as a+ // success, so the tile refreshed with no copy and the user kept clicking.+ lemonToast.error(e instanceof ApiError ? (e.detail ?? e.message) : 'Could not duplicate tile')+ throw e}},moveToDashboard: async ({ tile, fromDashboard, toDashboard }) => {