richardfogaca opened a new pull request, #40164: URL: https://github.com/apache/superset/pull/40164
### SUMMARY Defer the `ChartDataCommand` import in chart preview utilities until preview data is actually generated. `SUPPORTED_FORM_DATA_PREVIEW_FORMATS` is imported by MCP chart tool modules at module load time. Importing `ChartDataCommand` from the same module also loads chart command/model dependencies, which can initialize encrypted model fields before the Superset app is ready. Keeping the command import local preserves the preview behavior while making the lightweight constant safe to import during startup and CLI command discovery. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Not applicable. ### TESTING INSTRUCTIONS 1. `PYENV_VERSION=superset pytest tests/unit_tests/mcp_service/chart/test_preview_utils.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py::TestChartDataCommandValidation -q` 2. `ruff format --check superset/mcp_service/chart/preview_utils.py tests/unit_tests/mcp_service/chart/test_preview_utils.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py` 3. `ruff check superset/mcp_service/chart/preview_utils.py tests/unit_tests/mcp_service/chart/test_preview_utils.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py` 4. `PYENV_VERSION=superset pre-commit run --files superset/mcp_service/chart/preview_utils.py tests/unit_tests/mcp_service/chart/test_preview_utils.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py` Note: the focused pre-commit run passed through mypy and ruff, then failed in the pylint hook on existing environment/repo-wide findings outside these files: `.pylintrc` unknown `json-import` and `superset/db_engine_specs/base.py` `consider-using-transaction`. ### 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)) - [ ] 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 -- 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]
