You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mikebridge (via GitHub)" <gi...@apache.org> on 2026/10/22 20:52:04 UTC

[PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

mikebridge opened a new pull request, #45643:
URL: https://github.com/apache/superset/pull/45643

   **TL;DR:** when a bulk delete of semantic views is refused, the message now names only the views that are actually blocked, and offers to delete the others in one more step. Previously one blocked view made the message name every selected view.
   
   > **Depends on #45545.** This branch is stacked on it, so the diff includes its commits until it merges. Only the last commits belong to this PR.
   
   ### SUMMARY
   
   Bulk deleting semantic views stays all-or-nothing: if any selected view has dependents, nothing is deleted. What changes is how the refusal is reported.
   
   - **API.** The bulk delete 409 adds `blocked_view_ids`, the selected views that have dependents. It is computed only when the delete is refused. Existing fields are unchanged.
   - **Dataset list.** The refusal names only the blocked views. When some selected views aren't blocked, a confirmation names the blocked ones and offers to delete the others. It still needs the typed DELETE, because semantic views are deleted permanently.
   - **Bulk dialog copy.** The dialog no longer says the remaining items move to Recently Archived when the selection is only semantic views.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: selecting `cash_flow`, `gl_balances` and the blocked `revenue_by_region` gave "Could not delete semantic views cash_flow, gl_balances, revenue_by_region". After: "No semantic views were deleted because other assets depend on revenue_by_region. Delete the other semantic views, cash_flow, gl_balances?" If datasets were selected too, a toast reports the ones that were archived.
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/commands/semantic_layer/delete_test.py tests/unit_tests/semantic_layers/api_test.py`
   - `npm run test -- src/pages/DatasetList`
   - Manually, with `SEMANTIC_LAYERS` on: select two unused semantic views and one with a chart, then bulk delete. Only the blocked view is named, and confirming the follow-up deletes the other two.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags: `SEMANTIC_LAYERS`
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   `blocked_view_ids` costs one dependency check per selected view, and only on the refusal path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "aminghadersohi (via GitHub) via notifications" <no...@superset.apache.org>.
aminghadersohi commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4488541008


##########
superset/commands/semantic_layer/delete.py:
##########
@@ -413,6 +413,30 @@ def validate(self) -> None:
 
             if not current_user_can_modify_object(model):
                 raise SemanticViewForbiddenError()
-        _raise_for_dependents(
-            sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
-        )
+        try:
+            _raise_for_dependents(
+                sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
+            )
+        except SemanticDeleteDependentsError as ex:
+            # Refusal path only: one dependency check per selected view.
+            view_id: int
+            total: int
+            dependents: list[dict[str, str | int]]
+            inaccessible_count: int
+            archived_count: int
+            for view_id in self._model_ids:
+                total, dependents, inaccessible_count, archived_count = (
+                    _dependent_assets(sa.select(sa.literal(view_id)))
+                )

Review Comment:
   Yes, a follow-up works. `_dashboard_target_ids` (delete.py:102-120) returns one set for all selected ids, so a shared scan needs a per-view mapping in helpers outside this diff. The extra scans run only on a refused delete; 25 views over 2,000 dashboards took under 1s locally.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub) via notifications" <no...@superset.apache.org>.
codeant-ai-for-open-source[bot] commented on PR #45643:
URL: https://github.com/apache/superset/pull/45643#issuecomment-6645231193

   ## <a href="https://codeant.ai/" title="CodeAnt AI"><img src="https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/codeant-block-purple-v2.svg" width="28" height="28" align="absmiddle" style="vertical-align:middle" alt="CodeAnt" /></a>&nbsp; CodeAnt PR Risk
   
   **🟡&nbsp; Medium Risk**
   
   - The PR needs attention before merging.
   - On a refused bulk delete, dependency details are scanned once per selected view, so large requests may become slow or time out.
   
   **Assessed commit:** `f7b95482a120`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub) via notifications" <no...@superset.apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4474724491


##########
superset/commands/semantic_layer/delete.py:
##########
@@ -413,6 +413,30 @@ def validate(self) -> None:
 
             if not current_user_can_modify_object(model):
                 raise SemanticViewForbiddenError()
-        _raise_for_dependents(
-            sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
-        )
+        try:
+            _raise_for_dependents(
+                sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
+            )
+        except SemanticDeleteDependentsError as ex:
+            # Refusal path only: one dependency check per selected view.
+            view_id: int
+            total: int
+            dependents: list[dict[str, str | int]]
+            inaccessible_count: int
+            archived_count: int
+            for view_id in self._model_ids:
+                total, dependents, inaccessible_count, archived_count = (
+                    _dependent_assets(sa.select(sa.literal(view_id)))
+                )

Review Comment:
   **Suggestion:** This repeats the dependent-asset scan for every selected ID; the delete schema has no batch limit, so a large refused request can time out.
   
   **Assessment:** 🟠 `Major` · 🔁 `Occurrence: Rarely` · 🏷️ `Performance`
   
   [![Use CodeAnt Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5b3912baa28b4d05bd1bc1dcc7baf58a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5b3912baa28b4d05bd1bc1dcc7baf58a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/commands/semantic_layer/delete.py
   **Line:** 427:430
   **Comment:**
   	*Performance: This repeats the dependent-asset scan for every selected ID; the delete schema has no batch limit, so a large refused request can time out.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45643&comment_hash=2cd17b83ed425fc7a9836172fe2269ddc2c5412ec441c1793a70aaa68a5a7dda&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45643&comment_hash=2cd17b83ed425fc7a9836172fe2269ddc2c5412ec441c1793a70aaa68a5a7dda&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub) via notifications" <no...@superset.apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4487893873


##########
superset/commands/semantic_layer/delete.py:
##########
@@ -413,6 +413,30 @@ def validate(self) -> None:
 
             if not current_user_can_modify_object(model):
                 raise SemanticViewForbiddenError()
-        _raise_for_dependents(
-            sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
-        )
+        try:
+            _raise_for_dependents(
+                sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
+            )
+        except SemanticDeleteDependentsError as ex:
+            # Refusal path only: one dependency check per selected view.
+            view_id: int
+            total: int
+            dependents: list[dict[str, str | int]]
+            inaccessible_count: int
+            archived_count: int
+            for view_id in self._model_ids:
+                total, dependents, inaccessible_count, archived_count = (
+                    _dependent_assets(sa.select(sa.literal(view_id)))
+                )

Review Comment:
   Yes—keeping the attribution query out of this UI-focused change is reasonable, since the current helper’s aggregate result can’t safely identify which view each dependent blocks. But the performance concern is valid: on a refused request, this adds a dependent scan per selected view, and the API has no batch limit.
   
   I’d track a focused follow-up to return dependencies grouped by semantic-view ID from a shared scan. Until then, the repeated scans are confined to the refusal path, but large bulk requests remain a potential timeout risk.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #45643:
URL: https://github.com/apache/superset/pull/45643#issuecomment-6351088441

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 20875344c1adb7ac55601a22a552e0e98e15da00 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6ada7776ebe19bf6691b5759 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-45643--superset-docs-preview.netlify.app](https://deploy-preview-45643--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQ1NjQzLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.9N1JbM8H4VAm2Ty4ELNmfx0UtThNr3p49I-CTt0Lahg)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcoxDoAgDADAv3SWARMo-AOfQWmNCSgEcTDGv8t2w71QWzlqhwVgAmrhjPvwFZWenUOv6M5JsWTpoiiXmIRHZKm5PCuPagMHRLRCoj1t1npNBo2H7wc) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-45643--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "aminghadersohi (via GitHub) via notifications" <no...@superset.apache.org>.
aminghadersohi merged PR #45643:
URL: https://github.com/apache/superset/pull/45643


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "mikebridge (via GitHub) via notifications" <no...@superset.apache.org>.
mikebridge commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4487889940


##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1468,6 +1485,29 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
     );
   };
 
+  const showSemanticDeleteRefusal = async (
+    error: Parameters<typeof getClientErrorObject>[0],
+    semanticViews: Dataset[],
+  ) => {
+    const parsed = await getClientErrorObject(error);

Review Comment:
   Good catch. [f58c95f679](https://github.com/apache/superset/commit/f58c95f6793011ddeb06e9121dd0440345dc170a) applies your status guard to the shared bulk/retry handler, so only 409 opens the dependency dialog. The regression cases cover 403, 404, 422 and network failures on both paths.



##########
superset-frontend/src/pages/DatasetList/DatasetList.behavior.test.tsx:
##########
@@ -239,6 +296,159 @@ test('mixed bulk delete names refused semantic views and their conflict reason',
   ).toHaveLength(1);
 });
 
+test('refused bulk delete names only the blocked view and offers to delete the others', async () => {
+  const views = [
+    {
+      ...mockDatasets[0],
+      id: 98,
+      table_name: 'blocked_view',
+      kind: 'semantic_view',
+    },
+    {
+      ...mockDatasets[1],
+      id: 99,
+      table_name: 'free_view',
+      kind: 'semantic_view',
+    },
+  ];
+  const addSuccessToast = jest.fn();
+  const addDangerToast = jest.fn();
+  mockDatasetListEndpoints({ result: views, count: 2 });
+  fetchMock.get(API_ENDPOINTS.DATASET_BULK_RELATED_OBJECTS, {
+    charts: { count: 0, result: [] },
+    dashboards: { count: 0, result: [] },
+  });
+  fetchMock.delete('glob:*/api/v1/semantic_view/?q=!(98,99)', {
+    status: 409,
+    body: {
+      message: 'blocked',
+      total: 2,
+      blocked_view_ids: [98],
+      blocked_views: [
+        {
+          id: 98,
+          total: 2,
+          inaccessible_count: 1,
+          archived_count: 0,
+          dependents: [
+            { type: 'chart', id: 7, name: 'Retry blocker', archived: false },
+          ],
+        },
+      ],
+    },
+  });
+  fetchMock.delete('glob:*/api/v1/semantic_view/?q=!(99)', {
+    message: 'Deleted 1 semantic view',
+  });
+  renderDatasetList(mockAdminUser, { addDangerToast, addSuccessToast });
+  await screen.findByText('free_view');
+  await userEvent.click(screen.getByRole('button', { name: /bulk select/i }));
+  const table = screen.getByTestId('listview-table');
+  for (const name of ['blocked_view', 'free_view']) {
+    const cell = await within(table).findByText(name);
+    await userEvent.click(within(cell.closest('tr')!).getByRole('checkbox'));
+  }
+  await userEvent.click(
+    within(screen.getByTestId('bulk-select-controls')).getByRole('button', {
+      name: 'Delete',
+    }),
+  );
+  const bulkModal = await screen.findByRole('dialog');
+  expect(bulkModal).not.toHaveTextContent('moved to Recently Archived');

Review Comment:
   Good catch. The test enables SOFT_DELETE in [f58c95f679](https://github.com/apache/superset/commit/f58c95f6793011ddeb06e9121dd0440345dc170a), and removing the count guard makes it fail. Feature flags are restored after each test.



##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1525,15 +1565,15 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
           ? results[results.length - 1]
           : undefined;
         if (semanticResult?.status === 'rejected') {
-          await createErrorHandler(errMsg =>
-            addDangerToast(
-              t(
-                'Could not delete semantic views %s: %s',
-                semanticViews.map(view => view.table_name).join(', '),
-                errMsg,
-              ),
-            ),
-          )(semanticResult.reason);
+          await showSemanticDeleteRefusal(semanticResult.reason, semanticViews);
+        }
+        if (datasets.length && results[0].status === 'fulfilled') {
+          // The datasets went through even though the semantic views did not.
+          addSuccessToast(
+            softDelete
+              ? t('Archived %s item(s)', datasets.length)
+              : t('Deleted %s item(s)', datasets.length),
+          );
         }

Review Comment:
   Good catch. [f58c95f679](https://github.com/apache/superset/commit/f58c95f6793011ddeb06e9121dd0440345dc170a) keeps the Recently Archived link and the remembered dataset collection when the dataset part succeeds. The test checks both the soft-delete and hard-delete cases.



##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1552,6 +1592,48 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
     });
   };
 
+  const handleUnblockedRetry = () => {
+    if (!bulkDeleteRefusal) return;
+    const { unblocked } = bulkDeleteRefusal;
+    setBulkDeleteRefusal(null);
+    SupersetClient.delete({
+      endpoint: `/api/v1/semantic_view/?q=${rison.encode(
+        unblocked.map(({ id }) => id),
+      )}`,
+    }).then(
+      () => {
+        refreshData();
+        addSuccessToast(
+          tn(
+            'Deleted %s semantic view',
+            'Deleted %s semantic views',
+            unblocked.length,
+            unblocked.length,
+          ),
+        );
+      },
+      error => showSemanticDeleteRefusal(error, unblocked),

Review Comment:
   Good catch. [f58c95f679](https://github.com/apache/superset/commit/f58c95f6793011ddeb06e9121dd0440345dc170a) covers a retry that gets a fresh 409 with a new dependent and checks the replacement blocker details. Replacing that error handler with a no-op fails the test.



##########
superset/commands/semantic_layer/delete.py:
##########
@@ -413,6 +413,30 @@ def validate(self) -> None:
 
             if not current_user_can_modify_object(model):
                 raise SemanticViewForbiddenError()
-        _raise_for_dependents(
-            sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
-        )
+        try:
+            _raise_for_dependents(
+                sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
+            )
+        except SemanticDeleteDependentsError as ex:
+            # Refusal path only: one dependency check per selected view.
+            view_id: int
+            total: int
+            dependents: list[dict[str, str | int]]
+            inaccessible_count: int
+            archived_count: int
+            for view_id in self._model_ids:
+                total, dependents, inaccessible_count, archived_count = (
+                    _dependent_assets(sa.select(sa.literal(view_id)))
+                )

Review Comment:
   Would it be worth handling the shared scan as a separate performance follow-up? The current helper returns an aggregate dashboard-id set, so reusing its scan safely needs a per-view mapping to keep attribution; I kept that query change out of this UI error fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #45643:
URL: https://github.com/apache/superset/pull/45643#issuecomment-6351419140

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/45643?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `74.59016%` with `31 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 65.26%. Comparing base ([`aabddf5`](https://app.codecov.io/gh/apache/superset/commit/aabddf5b3f5d82b1b2598380ce2d3593784a977f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2087534`](https://app.codecov.io/gh/apache/superset/commit/20875344c1adb7ac55601a22a552e0e98e15da00?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/45643?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/commands/semantic\_layer/delete.py](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&filepath=superset%2Fcommands%2Fsemantic_layer%2Fdelete.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvc2VtYW50aWNfbGF5ZXIvZGVsZXRlLnB5) | 0.00% | [12 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [superset-frontend/src/pages/DatasetList/index.tsx](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fpages%2FDatasetList%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3BhZ2VzL0RhdGFzZXRMaXN0L2luZGV4LnRzeA==) | 86.56% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [superset/commands/semantic\_layer/exceptions.py](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&filepath=superset%2Fcommands%2Fsemantic_layer%2Fexceptions.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvc2VtYW50aWNfbGF5ZXIvZXhjZXB0aW9ucy5weQ==) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [superset-frontend/src/pages/DatabaseList/index.tsx](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fpages%2FDatabaseList%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3BhZ2VzL0RhdGFiYXNlTGlzdC9pbmRleC50c3g=) | 93.54% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45643?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (aabddf5) and HEAD (2087534). Click for more details.
   > 
   > <details><summary>HEAD has 4 uploads less than BASE</summary>
   >
   >| Flag | BASE (aabddf5) | HEAD (2087534) |
   >|------|------|------|
   >|python|7|3|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #45643       +/-   ##
   ===========================================
   - Coverage   84.11%   65.26%   -18.85%     
   ===========================================
     Files        3056     3056               
     Lines      201386   201521      +135     
     Branches    47088    47139       +51     
   ===========================================
   - Hits       169389   131527    -37862     
   - Misses      28751    67035    +38284     
   + Partials     3246     2959      -287     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.88% <0.00%> (+<0.01%)` | :arrow_up: |
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `80.16% <89.21%> (+<0.01%)` | :arrow_up: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.60% <0.00%> (-0.01%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `52.70% <0.00%> (-34.66%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `52.59% <0.00%> (-0.01%)` | :arrow_down: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/45643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/45643?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "aminghadersohi (via GitHub) via notifications" <no...@superset.apache.org>.
aminghadersohi commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4486498033


##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1525,15 +1565,15 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
           ? results[results.length - 1]
           : undefined;
         if (semanticResult?.status === 'rejected') {
-          await createErrorHandler(errMsg =>
-            addDangerToast(
-              t(
-                'Could not delete semantic views %s: %s',
-                semanticViews.map(view => view.table_name).join(', '),
-                errMsg,
-              ),
-            ),
-          )(semanticResult.reason);
+          await showSemanticDeleteRefusal(semanticResult.reason, semanticViews);
+        }
+        if (datasets.length && results[0].status === 'fulfilled') {
+          // The datasets went through even though the semantic views did not.
+          addSuccessToast(
+            softDelete
+              ? t('Archived %s item(s)', datasets.length)
+              : t('Deleted %s item(s)', datasets.length),
+          );
         }

Review Comment:
   Nit: With SOFT_DELETE on, this toast drops the Recently Archived link and the `rememberArchivedType('dataset')` call that the all-success path makes, so the archived datasets are harder to find.



##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1468,6 +1485,29 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
     );
   };
 
+  const showSemanticDeleteRefusal = async (
+    error: Parameters<typeof getClientErrorObject>[0],
+    semanticViews: Dataset[],
+  ) => {
+    const parsed = await getClientErrorObject(error);

Review Comment:
   A 403, 404, 422 or network failure on the bulk or retry delete opens the 'Cannot delete semantic views' dialog, repeating the error under every view with a Recently Archived link and no toast. Only a 409 is a dependency refusal, as in the single-row handler.
   
   ```suggestion
       const parsed = await getClientErrorObject(error);
       if (parsed.status !== 409) {
         const names = semanticViews.map(view => view.table_name).join(', ');
         addDangerToast(
           t('There was an issue deleting %s: %s', names, parsed.error),
         );
         return;
       }
   ```



##########
superset-frontend/src/pages/DatasetList/DatasetList.behavior.test.tsx:
##########
@@ -239,6 +296,159 @@ test('mixed bulk delete names refused semantic views and their conflict reason',
   ).toHaveLength(1);
 });
 
+test('refused bulk delete names only the blocked view and offers to delete the others', async () => {
+  const views = [
+    {
+      ...mockDatasets[0],
+      id: 98,
+      table_name: 'blocked_view',
+      kind: 'semantic_view',
+    },
+    {
+      ...mockDatasets[1],
+      id: 99,
+      table_name: 'free_view',
+      kind: 'semantic_view',
+    },
+  ];
+  const addSuccessToast = jest.fn();
+  const addDangerToast = jest.fn();
+  mockDatasetListEndpoints({ result: views, count: 2 });
+  fetchMock.get(API_ENDPOINTS.DATASET_BULK_RELATED_OBJECTS, {
+    charts: { count: 0, result: [] },
+    dashboards: { count: 0, result: [] },
+  });
+  fetchMock.delete('glob:*/api/v1/semantic_view/?q=!(98,99)', {
+    status: 409,
+    body: {
+      message: 'blocked',
+      total: 2,
+      blocked_view_ids: [98],
+      blocked_views: [
+        {
+          id: 98,
+          total: 2,
+          inaccessible_count: 1,
+          archived_count: 0,
+          dependents: [
+            { type: 'chart', id: 7, name: 'Retry blocker', archived: false },
+          ],
+        },
+      ],
+    },
+  });
+  fetchMock.delete('glob:*/api/v1/semantic_view/?q=!(99)', {
+    message: 'Deleted 1 semantic view',
+  });
+  renderDatasetList(mockAdminUser, { addDangerToast, addSuccessToast });
+  await screen.findByText('free_view');
+  await userEvent.click(screen.getByRole('button', { name: /bulk select/i }));
+  const table = screen.getByTestId('listview-table');
+  for (const name of ['blocked_view', 'free_view']) {
+    const cell = await within(table).findByText(name);
+    await userEvent.click(within(cell.closest('tr')!).getByRole('checkbox'));
+  }
+  await userEvent.click(
+    within(screen.getByTestId('bulk-select-controls')).getByRole('button', {
+      name: 'Delete',
+    }),
+  );
+  const bulkModal = await screen.findByRole('dialog');
+  expect(bulkModal).not.toHaveTextContent('moved to Recently Archived');

Review Comment:
   Nit: SOFT_DELETE is off in this file, so the archive copy never renders and this assertion still passes with the `pendingBulkCount > pendingBulkSemanticCount` guard removed. Turn the flag on for this check.



##########
superset-frontend/src/pages/DatasetList/index.tsx:
##########
@@ -1552,6 +1592,48 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
     });
   };
 
+  const handleUnblockedRetry = () => {
+    if (!bulkDeleteRefusal) return;
+    const { unblocked } = bulkDeleteRefusal;
+    setBulkDeleteRefusal(null);
+    SupersetClient.delete({
+      endpoint: `/api/v1/semantic_view/?q=${rison.encode(
+        unblocked.map(({ id }) => id),
+      )}`,
+    }).then(
+      () => {
+        refreshData();
+        addSuccessToast(
+          tn(
+            'Deleted %s semantic view',
+            'Deleted %s semantic views',
+            unblocked.length,
+            unblocked.length,
+          ),
+        );
+      },
+      error => showSemanticDeleteRefusal(error, unblocked),

Review Comment:
   Nit: No test covers a retry that is refused again, e.g. a view gains a dependent between the two steps: replacing this handler with a no-op leaves every DatasetList test passing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic): name only the blocked views when a bulk semantic view delete is refused [superset]

Posted by "aminghadersohi (via GitHub) via notifications" <no...@superset.apache.org>.
aminghadersohi commented on code in PR #45643:
URL: https://github.com/apache/superset/pull/45643#discussion_r4486505012


##########
superset/commands/semantic_layer/delete.py:
##########
@@ -413,6 +413,30 @@ def validate(self) -> None:
 
             if not current_user_can_modify_object(model):
                 raise SemanticViewForbiddenError()
-        _raise_for_dependents(
-            sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
-        )
+        try:
+            _raise_for_dependents(
+                sa.select(SemanticView.id).where(SemanticView.id.in_(self._model_ids))
+            )
+        except SemanticDeleteDependentsError as ex:
+            # Refusal path only: one dependency check per selected view.
+            view_id: int
+            total: int
+            dependents: list[dict[str, str | int]]
+            inaccessible_count: int
+            archived_count: int
+            for view_id in self._model_ids:
+                total, dependents, inaccessible_count, archived_count = (
+                    _dependent_assets(sa.select(sa.literal(view_id)))
+                )

Review Comment:
   Valid but minor: the refusal path runs 3 extra statements per selected view (11 for 2 views, 65 for 20), each re-reading dashboard metadata. It runs only after every id passes the modify check, and the ids travel in the URL. Hoisting the dashboard scan out of the loop would cap it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org