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

   ### SUMMARY
   
   The v1 dataset importer persisted a dataset's `catalog` without validating 
it against the target database connection, unlike the dataset update path. When 
the connection has multi-catalog disabled (`allow_multi_catalog` off) and the 
imported catalog is not the connection's default catalog, the import succeeded 
and the dataset then executed queries against a different physical database. 
When the source and target databases live on the same server, this silently 
routes queries to the wrong database and shows incorrect data in charts and 
dashboards. With overwrite enabled, a UUID-matched import could flip an 
existing, correctly-bound dataset into this state.
   
   `import_dataset` now validates the catalog and raises the same 
`MultiCatalogDisabledValidationError` the update command uses. The import 
command converts it to a `CommandInvalidError` so the API returns a 422 with 
the catalog message ("Only the default catalog is supported for this 
connection") instead of a generic failure.
   
   Validation only triggers when the target database supports catalogs and has 
a known default catalog. Databases without catalog support, and a `None`/absent 
catalog (which resolves to the connection's default at query time), are left 
unaffected, so existing imports keep working.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A, backend validation with no UI changes.
   
   ### TESTING INSTRUCTIONS
   
   Unit tests:
   
   ```
   pytest tests/unit_tests/datasets/commands/importers/v1/import_test.py
   ```
   
   Coverage added: a non-default catalog with multi-catalog off raises; the 
import command surfaces it as a validation error; overwrite cannot flip an 
existing dataset's catalog; a non-default catalog is allowed when multi-catalog 
is on; the default catalog is allowed when multi-catalog is off.
   
   Manual:
   
   1. On a catalog-supporting connection (e.g. Postgres) with "Allow changing 
catalogs" off, create a dataset and export it.
   2. Edit `catalog:` in the dataset YAML to a non-default catalog and re-zip.
   3. Import with Overwrite enabled. The import now fails with "Only the 
default catalog is supported for this connection" instead of silently 
persisting the non-default catalog.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


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