Skip to content

: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.

fix(data-quality): stop the editor's own validation blocking save (#94936)

Julian Bez1b06879e6b66
diff --git a/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts b/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts
index b7799c85c0a8..f4cd2abddbbd 100644
--- a/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts
+++ b/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts
@@ -447,6 +447,32 @@ describe('dataQualityCheckEditorLogic', () => {
expect(logic.values.checkFormErrors.customSql).toEqual('Checking query...')
})
+ it('saves a query nobody edited while Monaco validates the one it opened with', async () => {
+ // Monaco validates the query as soon as the editor mounts. That pass is not an edit, so it
+ // must not hold the save while it runs.
+ ;(warehouseSavedQueriesChecksPartialUpdate as jest.Mock).mockResolvedValue(buildCheck())
+ await mountLogic()
+ await openWith(
+ buildCheck({
+ check_type: CheckTypeEnumApi.CustomSql,
+ column_name: '',
+ config: { query: 'SELECT id FROM orders' },
+ }),
+ { description: 'Every order keeps a positive id' }
+ )
+
+ logic.actions.setCustomSqlValidationLoading(true)
+ logic.actions.submitCheckForm()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(warehouseSavedQueriesChecksPartialUpdate).toHaveBeenCalledWith(
+ '1',
+ 'view-1',
+ 'check-1',
+ expect.objectContaining({ description: 'Every order keeps a positive id' })
+ )
+ })
+
it('keeps a Monaco error until an edited query receives a new validation result', async () => {
await mountLogic()
await openWith(null, { checkType: 'custom_sql', customSql: 'SELECT * FROM orders' })
diff --git a/products/data_quality/frontend/dataQualityCheckEditorLogic.ts b/products/data_quality/frontend/dataQualityCheckEditorLogic.ts
index c80d5c83bfec..0755f26c15cd 100644
--- a/products/data_quality/frontend/dataQualityCheckEditorLogic.ts
+++ b/products/data_quality/frontend/dataQualityCheckEditorLogic.ts
@@ -595,7 +595,10 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(
customSqlValidationLoading: [
false,
{
- setCustomSqlValidationLoading: (_, { loading }) => loading,
+ // An edit is what starts the wait, so the editor can only end it. The editor also
+ // validates the query it was opened with, and that pass must not block saving a
+ // check whose query nobody touched.
+ setCustomSqlValidationLoading: (state, { loading }) => state && loading,
openEditor: () => false,
setCheckFormValue: (state, { name }) =>
name === 'customSql' ? true : name === 'checkType' ? false : state,