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

   ### Summary
   
   Fixes #44304 (the live remainder on current master; see the analysis in the 
issue).
   
   A dashboard import whose UUID is fresh but whose slug is owned by another 
**active** dashboard used to pass `_prevent_overwrite_existing_model()` 
(UUID-only), then `import_dashboard()` resolved the config onto the slug-owning 
row:
   
   - without `overwrite` the bundle's charts **silently merged** into the 
slug-owning dashboard — no error, and the OVERWRITE confirmation the 
ImportModal shows for UUID collisions never appeared;
   - with `overwrite` confirmed the import replaced a dashboard the user never 
saw in the prompt (the prompt lists files, and the collision was invisible).
   
   ### What changed
   
   `ImportDashboardsCommand._prevent_overwrite_existing_model()` now also flags 
a config whose non-empty slug is owned by a *different* active dashboard, 
emitting the exact same message the UUID branch emits (`already exists and 
`overwrite=true` was not passed`) — that is the string `isAlreadyExists()` in 
`superset-frontend/src/views/CRUD/utils.tsx` matches, so the existing OVERWRITE 
confirmation flow starts covering slug collisions with no frontend change. 
After the user confirms, the import proceeds through the slug-resolution and 
permission/editorship gates already present in `import_dashboard()` (#42582).
   
   Scope kept deliberately narrow:
   - same-UUID hits keep coming from the base check (no double reporting);
   - `slug=None`/empty-slug configs are not flagged;
   - soft-deleted slug owners are left to the existing restore path;
   - other importers (charts/datasets/databases) are untouched — `slug` as an 
import identity key is dashboard-specific.
   
   ### Testing
   
   - `test_import_slug_collision_flags_overwrite_confirm` — colliding slug 
fails validation with the exact message the ImportModal matches on;
   - `test_import_slug_collision_with_overwrite_passes_gate` — with `overwrite` 
the gate passes (slug-resolution + permission gates take over);
   - `test_import_no_slug_collision_passes_gate` — fresh slug and slugless 
configs pass;
   - `test_import_slug_collision_same_uuid_not_flagged` — same-UUID config 
yields exactly one validation error (UUID branch), no duplicate from the slug 
branch.
   
   RED verified (test fails on unpatched master), GREEN with the fix; full 
suite `tests/unit_tests/dashboards/commands/importers/` passes (45 tests).
   
   ### Additional context
   
   The reporter's 6.1.0 chain (`IntegrityError` → generic "unknown reason" 
message) no longer reproduces on master since #42582; this PR closes the 
remaining gap the issue is actually about: slug collisions must be surfaced as 
an existing-resource conflict, not swallowed. Reporter's env: 6.1.0.
   
   PR created by a FOSS contributor; happy to adjust shape (e.g. move the check 
into the base class behind a per-model hook) if maintainers prefer.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to