You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/02/22 22:15:00 UTC
[PR] fix(dashboard): replace chartsInScope references at import time [superset]
rusackas opened a new pull request, #38171:
URL: https://github.com/apache/superset/pull/38171
### SUMMARY
**Originally authored by @rdubois-kh in #26389** - This PR adopts and rebases the original contribution.
This PR fixes issue #26338: `chartsInScope` references are not fixed during a Dashboard import.
When a dashboard is imported using the `ImportDashboardsCommand` (v1), the chart ID references need to be updated to use the IDs of the newly created charts in the target instance. The original code was missing updates for `chartsInScope` references in several places:
1. **Native filter configuration** - `chartsInScope` in `native_filter_configuration` entries
2. **Global chart configuration** - `chartsInScope` in `global_chart_configuration`
3. **Per-chart cross-filter configuration** - `chartsInScope` in `chart_configuration[id].crossFilters`
This resulted in broken filter scoping after dashboard imports, where filters would reference old chart IDs that don't exist in the target instance.
**Changes made:**
- Added `chartsInScope` remapping in `update_id_refs()` for native filters
- Added `chartsInScope` remapping in `update_cross_filter_scoping()` for global and per-chart configurations
- Refactored `update_cross_filter_scoping()` to extract helper functions `_remap_chart_ids()` and `_update_cross_filter_scope()` to reduce complexity
- Added comprehensive unit tests for the new functionality
Fixes #26338
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend-only change
### TESTING INSTRUCTIONS
1. Create a dashboard with charts and configure native filters with specific charts in scope
2. Export the dashboard
3. Modify the exported ZIP to change chart UUIDs (simulating import to a different instance)
4. Import the modified dashboard
5. Verify that `chartsInScope` in the imported dashboard's `json_metadata` contains the correct new chart IDs
Or run the unit tests:
```bash
pytest tests/unit_tests/dashboards/commands/importers/v1/utils_test.py -v
```
### ADDITIONAL INFORMATION
- [x] Has associated issue: #26338
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
---
**Attribution:** This PR adopts the work from #26389 by @rdubois-kh. The original PR needed a rebase due to conflicts with recent changes to the cross-filter scoping code.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4297925474
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/38171?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 `20.93023%` with `34 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 63.76%. Comparing base ([`72d39be`](https://app.codecov.io/gh/apache/superset/commit/72d39bea857b929246cd9dd74f8480c173da0cd4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`047e64e`](https://app.codecov.io/gh/apache/superset/commit/047e64e107da8fca84210a158e7bbb40df75c817?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/38171?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/dashboard/importers/v1/utils.py](https://app.codecov.io/gh/apache/superset/pull/38171?src=pr&el=tree&filepath=superset%2Fcommands%2Fdashboard%2Fimporters%2Fv1%2Futils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvZGFzaGJvYXJkL2ltcG9ydGVycy92MS91dGlscy5weQ==) | 20.93% | [30 Missing and 4 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/38171?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #38171 +/- ##
==========================================
+ Coverage 55.54% 63.76% +8.22%
==========================================
Files 2564 2564
Lines 133558 133580 +22
Branches 31031 31039 +8
==========================================
+ Hits 74179 85181 +11002
+ Misses 58728 46887 -11841
- Partials 651 1512 +861
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/38171/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/38171/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.86% <4.65%> (-0.02%)` | :arrow_down: |
| [presto](https://app.codecov.io/gh/apache/superset/pull/38171/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.64% <4.65%> (-0.02%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/38171/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.27% <20.93%> (+18.54%)` | :arrow_up: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/38171/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.14% <20.93%> (?)` | |
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 Sentry](https://app.codecov.io/gh/apache/superset/pull/38171?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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2920459949
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map
+ )
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
+ except (TypeError, ValueError):
+ continue
+
+ new_id = id_map.get(old_id_int)
+ if new_id is None:
+ continue
+
+ if isinstance(chart_config, dict):
+ chart_config["id"] = new_id
+ if cross_filters := chart_config.get("crossFilters", {}):
+ _update_cross_filter_scope(cross_filters, id_map)
+
+ new_chart_configuration[str(new_id)] = chart_config
+
+ metadata["chart_configuration"] = new_chart_configuration
Review Comment:
Good catch — this is a valid bug. Fixed: non-integer keys (e.g. UUID-based configs from example exports) are now preserved unchanged, and only numeric-ID keys are remapped. Added a unit test to cover this case.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2915194393
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map
+ )
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
+ except (TypeError, ValueError):
+ continue
+
+ new_id = id_map.get(old_id_int)
+ if new_id is None:
+ continue
+
+ if isinstance(chart_config, dict):
+ chart_config["id"] = new_id
+ if cross_filters := chart_config.get("crossFilters", {}):
+ _update_cross_filter_scope(cross_filters, id_map)
+
+ new_chart_configuration[str(new_id)] = chart_config
+
+ metadata["chart_configuration"] = new_chart_configuration
Review Comment:
**Suggestion:** The new `update_cross_filter_scoping` logic assumes that all `chart_configuration` keys are stringified integers and drops any entries whose keys cannot be parsed as `int`. However, other parts of the codebase (e.g. `export_example.remap_chart_configuration`) explicitly produce `chart_configuration` keyed by UUID strings, and those dashboards can later be exported via the regular dashboard export and re-imported through this importer. In that scenario, all UUID-keyed cross-filter configurations will be silently removed on import, breaking cross-filter behavior. Instead, non-integer keys should be preserved unchanged and only numeric-ID keys remapped. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Cross-filter configuration lost for UUID-keyed chart_configuration entries.
- ⚠️ Dashboards imported from example exports lose cross-filter behavior.
- ⚠️ Users must manually reconfigure cross-filter scoping after import.
```
</details>
```suggestion
new_chart_configuration: dict[str, Any] = {}
for old_id_str, chart_config in metadata["chart_configuration"].items():
try:
old_id_int = int(old_id_str)
except (TypeError, ValueError):
# Preserve non-integer keys (e.g. UUID-based configs) unchanged
new_chart_configuration[old_id_str] = chart_config
continue
new_id = id_map.get(old_id_int)
if new_id is None:
# Skip numeric IDs that aren't part of this import
continue
if isinstance(chart_config, dict):
chart_config["id"] = new_id
if cross_filters := chart_config.get("crossFilters", {}):
_update_cross_filter_scope(cross_filters, id_map)
new_chart_configuration[str(new_id)] = chart_config
metadata["chart_configuration"] = new_chart_configuration
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Export a dashboard that has cross-filter configuration (`chart_configuration` in
`json_metadata`) using the example export path: run `ExportExampleCommand` (defined in
`superset/commands/dashboard/export_example.py:487`) which calls `export_dashboard_yaml`
at `export_example.py:391`.
2. Inside `export_dashboard_yaml`, the original `json_metadata["chart_configuration"]`
(keyed by integer chart IDs) is passed to `remap_chart_configuration` at
`export_example.py:347-375`. That function builds a new dict `remapped` keyed by chart
UUID strings (see `remapped[chart_uuid] = new_config` at line 373), so the resulting
`dashboard.yaml` has `metadata["chart_configuration"]` keyed by UUIDs, not integers.
3. Import this generated dashboard bundle through the regular v1 dashboard importer (e.g.
via the dashboards API which instantiates `ImportDashboardsCommand` as seen in
`superset/dashboards/api.py:1944`, or via CLI import which uses `ImportDashboardsCommand`
in `superset/cli/importexport.py:158`). During import, each dashboard config is passed
into `update_id_refs` in `superset/commands/dashboard/importers/v1/utils.py:60-151`.
4. `update_id_refs` calls `update_cross_filter_scoping` at `utils.py:150`, which iterates
`metadata["chart_configuration"]` in `update_cross_filter_scoping` at `utils.py:187-205`.
For each entry, it executes `old_id_int = int(old_id_str)` at line 190; for UUID keys this
raises `ValueError`, triggering the `except (TypeError, ValueError): continue` at line
191. As a result, every UUID-keyed `chart_configuration` entry is skipped and never added
to `new_chart_configuration`. After the loop, `metadata["chart_configuration"] =
new_chart_configuration` at line 205 replaces the original UUID-keyed configuration with a
dict containing only integer-keyed entries (often empty), silently dropping all
cross-filter configuration for those charts on the imported dashboard.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/dashboard/importers/v1/utils.py
**Line:** 187:205
**Comment:**
*Logic Error: The new `update_cross_filter_scoping` logic assumes that all `chart_configuration` keys are stringified integers and drops any entries whose keys cannot be parsed as `int`. However, other parts of the codebase (e.g. `export_example.remap_chart_configuration`) explicitly produce `chart_configuration` keyed by UUID strings, and those dashboards can later be exported via the regular dashboard export and re-imported through this importer. In that scenario, all UUID-keyed cross-filter configurations will be silently removed on import, breaking cross-filter behavior. Instead, non-integer keys should be preserved unchanged and only numeric-ID keys remapped.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=78b8d16403deacb7e4dde506d4a103011dc145d2fa0f222221ad440e84a96783&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=78b8d16403deacb7e4dde506d4a103011dc145d2fa0f222221ad440e84a96783&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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2838582911
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
Review Comment:
**Suggestion:** The new `update_cross_filter_scoping` implementation assumes that `metadata["chart_configuration"]` is keyed by numeric chart IDs (strings convertible to `int`), but `export_example.remap_chart_configuration` writes example dashboards with `chart_configuration` keyed by chart UUIDs; as a result, per-chart cross-filter configurations from example exports are silently skipped on import, and user-defined cross-filter scoping is lost. To fix this, when a key cannot be parsed as an int, also look it up as a UUID using the position data (via `build_uuid_to_id_map`) so both numeric-ID and UUID-keyed configurations are correctly remapped. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Example dashboards lose per-chart cross-filter configurations on import.
- ⚠️ Cross-filter scoping from export_example not preserved in metadata.
- ⚠️ Users of example bundles see cross-filtering disabled or incorrect.
```
</details>
```suggestion
# Some exporters (e.g. export_example) key chart_configuration by chart UUID
# instead of numeric chart id. Build a UUID -> old_id map from the position
# data so we can handle both formats.
old_ids = build_uuid_to_id_map(fixed.get("position", {}))
for old_id_str, chart_config in metadata["chart_configuration"].items():
old_id_int = None
try:
old_id_int = int(old_id_str)
except (TypeError, ValueError):
# Fallback: treat key as a chart UUID and resolve via position
old_id_int = old_ids.get(old_id_str)
if old_id_int is None:
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Export a dashboard with cross-filters using the example exporter: call
`ExportExampleCommand.run()` in `superset/commands/dashboard/export_example.py:487-672`,
which internally calls `export_dashboard_yaml()` at `export_example.py:391-459`.
2. In `export_dashboard_yaml()`, observe that `chart_configuration` is remapped by
`remap_chart_configuration()` at `export_example.py:347-375`, producing metadata where
`metadata["chart_configuration"]` is keyed by chart UUID strings and each entry's `"id"`
and `"crossFilters"]["chartsInScope"]` also contain chart UUIDs.
3. Import the generated `dashboard.yaml` via the v1 dashboards importer (e.g. through the
dashboards API, which constructs an `ImportDashboardsCommand` at
`superset/dashboards/api.py:1940`); the v1 importer wires `update_id_refs()` into the
import pipeline at `superset/commands/dashboard/importers/v1/__init__.py:174` (`config =
update_id_refs(config, chart_ids, dataset_info)`).
4. Inside `update_id_refs()` (`superset/commands/dashboard/importers/v1/utils.py:60-151`),
the function calls `update_cross_filter_scoping(fixed, id_map)` at `utils.py:150`; in
`update_cross_filter_scoping()` (`utils.py:172-205`), the loop at `utils.py:188-192`
attempts `int(old_id_str)` for each `metadata["chart_configuration"]` key, but since keys
are UUID strings from the example export, `int()` raises `ValueError`, causing the
`except` block at `utils.py:191-192` to `continue` and skip each entry, resulting in
`new_chart_configuration` remaining empty and `metadata["chart_configuration"]` being set
to `{}` at `utils.py:205`, thereby dropping all per-chart cross-filter configuration on
the imported dashboard.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/dashboard/importers/v1/utils.py
**Line:** 188:190
**Comment:**
*Logic Error: The new `update_cross_filter_scoping` implementation assumes that `metadata["chart_configuration"]` is keyed by numeric chart IDs (strings convertible to `int`), but `export_example.remap_chart_configuration` writes example dashboards with `chart_configuration` keyed by chart UUIDs; as a result, per-chart cross-filter configurations from example exports are silently skipped on import, and user-defined cross-filter scoping is lost. To fix this, when a key cannot be parsed as an int, also look it up as a UUID using the position data (via `build_uuid_to_id_map`) so both numeric-ID and UUID-keyed configurations are correctly remapped.
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.
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=c1472a6e5b564fc51c6b9fea7d45ca0103a74d0b24e453221e5ffc1c7b33808e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=c1472a6e5b564fc51c6b9fea7d45ca0103a74d0b24e453221e5ffc1c7b33808e&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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4035314323
## **Sequence Diagram**
This PR ensures that during dashboard import, all chartsInScope and related cross-filter scope references are remapped to the newly created chart IDs so that native filters and cross-filters target the correct charts.
```mermaid
sequenceDiagram
participant Importer
participant IdRefUpdater
participant NativeFilterConfig
participant CrossFilterConfig
Importer->>IdRefUpdater: Update dashboard config with new chart ids
IdRefUpdater->>NativeFilterConfig: Remap chartsInScope and excluded chart ids
IdRefUpdater->>CrossFilterConfig: Remap chartsInScope and excluded chart ids
CrossFilterConfig-->>IdRefUpdater: Updated cross filter metadata
IdRefUpdater-->>Importer: Return fixed dashboard configuration
```
---
*Generated by [CodeAnt AI](https://codeant.ai)*
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4484604634
Heads up — tried a master rebase as part of a maintenance sweep and hit semantic conflicts in `superset/commands/dashboard/importers/v1/utils.py` + its test file. Note that #40140 also touches `update_id_refs` to remap `chartsInScope` (same root issue #26338); whichever lands first will need a small follow-up here.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4041788001
Addressed all open review comments and pushed updates:
- **[Copilot]** `chartsInScope` in native filters now uses `_remap_chart_ids` helper for consistency ✅ (already applied in a prior commit)
- **[CodeAnt #1 & #2]** UUID-keyed `chart_configuration` entries (produced by `export_example`) are now **fully remapped** to new integer IDs rather than silently dropped or preserved as-is:
- Built a `uuid_to_new_id` map alongside `id_map` in `update_id_refs`
- Propagated through `update_cross_filter_scoping`, `_update_cross_filter_scope`, and `_remap_chart_ids`
- UUID keys in `chart_configuration` → resolved to new integer keys
- UUID values in `chartsInScope` → remapped to new integer IDs
- Unknown UUID keys → preserved unchanged as a safe fallback
- Native filter `chartsInScope` also handles UUID values from example exports
- Tests updated to cover the full example-export remapping case
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r3125328291
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +140,101 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
- fixed = update_cross_filter_scoping(fixed, id_map)
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map, uuid_to_new_id
+ )
+
+ fixed = update_cross_filter_scoping(fixed, id_map, uuid_to_new_id)
return fixed
+def _remap_chart_ids(
+ id_list: list[Any],
+ id_map: dict[int, int],
+ uuid_to_new_id: dict[str, int] | None = None,
+) -> list[int]:
+ """Remap old chart IDs (int or UUID string) to new integer IDs.
+
+ Handles both the standard import format (integer IDs) and the example-export
+ format (UUID strings produced by export_example.remap_chart_configuration).
+ """
+ result = []
+ for item in id_list:
+ if isinstance(item, int):
+ if item in id_map:
+ result.append(id_map[item])
+ elif isinstance(item, str) and uuid_to_new_id:
+ new_id = uuid_to_new_id.get(item)
+ if new_id is not None:
+ result.append(new_id)
+ return result
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any],
+ id_map: dict[int, int],
+ uuid_to_new_id: dict[str, int] | None = None,
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map, uuid_to_new_id)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map, uuid_to_new_id
+ )
Review Comment:
**Suggestion:** `_update_cross_filter_scope` assumes `cross_filter_config` is always a dict and calls `.get()` unconditionally. Since imported dashboard metadata is only loosely validated (`metadata` is a generic dict), malformed payloads like `global_chart_configuration: null` or non-dict `crossFilters` will raise `AttributeError` at import time. Add a type guard at the start of this helper (and/or before calling it) to skip non-dict values safely. [type error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ V1 dashboard imports can crash on malformed cross-filter metadata.
- ⚠️ Admins may be unable to import some edited dashboards.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Trigger a v1 dashboard import via `ImportDashboardsCommand._import` in
`superset/commands/dashboard/importers/v1/__init__.py:55-183` using a `dashboards/...yaml`
payload whose parsed `config` contains `"metadata": {"global_chart_configuration": null}`
(JSON `null` -> Python `None`) along with a valid `"position"` section so `chart_ids` can
be built.
2. In `_import`, for each dashboards entry, line 174 (`config = update_id_refs(config,
chart_ids, dataset_info)`) calls `update_id_refs` in
`superset/commands/dashboard/importers/v1/utils.py:60-152` with this `config`.
3. Inside `update_id_refs`, at `utils.py:151`, `fixed = update_cross_filter_scoping(fixed,
id_map, uuid_to_new_id)` is executed; `update_cross_filter_scoping` at `utils.py:194-237`
does `metadata = fixed.get("metadata", {})` then `global_config =
metadata.get("global_chart_configuration", {})`, which returns `None` because the key
exists with value `null` in the payload.
4. `update_cross_filter_scoping` passes this `None` into `_update_cross_filter_scope` at
`utils.py:177-191`; the helper immediately evaluates `scope =
cross_filter_config.get("scope", {})` at line 183. Because `cross_filter_config` is
`None`, this raises `AttributeError: 'NoneType' object has no attribute 'get'`, causing
the entire v1 dashboard import to fail instead of skipping the malformed
`global_chart_configuration`. The same failure pattern occurs if a chart's `crossFilters`
value is a non-dict truthy object (e.g. a non-empty list) due to the call
`_update_cross_filter_scope(cross_filters, ...)` at `utils.py:232-233`.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fcommands%2Fdashboard%2Fimporters%2Fv1%2Futils.py%0A%2A%2ALine%3A%2A%2A%20183%3A191%0A%2A%2AComment%3A%2A%2A%0A%09%2AType%20Error%3A%20%60_update_cross_filter_scope%60%20assumes%20%60cross_filter_config%60%20is%20always%20a%20dict%20and%20calls%20%60.get%28%29%60%20unconditionally.%20Since%20imported%20dashboard%20metadata%20is%20only%20loosely%20validated%20%28%60metadata%60%20is%20a%20generic%20dict%29%2C%20malformed%20payloads%20like%20%60global_chart_configuration%3A%20null%60%20or%20non-dict%20%60crossFilters%60%20will%20raise%20%60AttributeError%60%20at%20import%20time.%20Add%20a%20type%20guard%20at%20the%20start%20of%20this%20helper%20%28and%2For%20before%20calling%20it%29%20to%20skip%20non-dict%20values%20safely.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I
%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fcommands%2Fdashboard%2Fimporters%2Fv1%2Futils.py%0A%2A%2ALine%3A%2A%2A%20183%3A191%0A%2A%2AComment%3A%2A%2A%0A%09%2AType%20Error%3A%20%60_update_cross_filter_scope%60%20assumes%20%60cross_filter_config%60%20is%20always%20a%20dict%20and%20calls%20%60.get%28%29%60%20unconditionally.%20Since%20imported%20dashboard%20metadata%20is%20only%20loosely%20validated%20%28%60metada
ta%60%20is%20a%20generic%20dict%29%2C%20malformed%20payloads%20like%20%60global_chart_configuration%3A%20null%60%20or%20non-dict%20%60crossFilters%60%20will%20raise%20%60AttributeError%60%20at%20import%20time.%20Add%20a%20type%20guard%20at%20the%20start%20of%20this%20helper%20%28and%2For%20before%20calling%20it%29%20to%20skip%20non-dict%20values%20safely.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/dashboard/importers/v1/utils.py
**Line:** 183:191
**Comment:**
*Type Error: `_update_cross_filter_scope` assumes `cross_filter_config` is always a dict and calls `.get()` unconditionally. Since imported dashboard metadata is only loosely validated (`metadata` is a generic dict), malformed payloads like `global_chart_configuration: null` or non-dict `crossFilters` will raise `AttributeError` at import time. Add a type guard at the start of this helper (and/or before calling it) to skip non-dict values safely.
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%2F38171&comment_hash=2196e85f51ccf876d8f5f31010bd6e0e5552ff2679e3e60318905ce1175f87dc&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=2196e85f51ccf876d8f5f31010bd6e0e5552ff2679e3e60318905ce1175f87dc&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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4298299112
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4041586464
Addressed in the latest commit: https://github.com/apache/superset/pull/38171#discussion_r2915194393 — non-integer keys (e.g. UUID-based configs from example exports) are now preserved unchanged in `update_cross_filter_scoping`, and only numeric-ID keys are remapped. Added a unit test to cover this case.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-3941808758
<!-- Answer -->
**Related Documentation**
Checked 0 published document(s) in 2 knowledge base(s). No updates required.
<!-- Dosu Comment Footer -->
<sup>How did I do? Any feedback?</sup> [](https://go.dosu.dev/discord-bot)
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r3125294565
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this new test function (for example, `-> None`) to ensure new function definitions are fully typed. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The added test function lacks a return annotation such as `-> None`. Under the stated typing rule for new Python definitions, this is a real violation.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20336%3A336%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20ensure%20new%20function%20definitions%20are%20fully%20typed.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20
the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20336%3A336%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20ensure%20new%20function%20definitions%20are%20fully%20typed.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well
.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/dashboards/commands/importers/v1/utils_test.py
**Line:** 336:336
**Comment:**
*Custom Rule: Add an explicit return type annotation to this new test function (for example, `-> None`) to ensure new function definitions are fully typed.
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%2F38171&comment_hash=88e93c5fcb80924e2d64f8b98aa86c08e99f04054b2a738bc3e2aeb0af27b571&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=88e93c5fcb80924e2d64f8b98aa86c08e99f04054b2a738bc3e2aeb0af27b571&reaction=dislike'>👎</a>
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
+ """
+ Test that UUID-keyed chart_configuration entries (from example exports) are
+ properly remapped to new integer IDs during import, including UUID values in
+ chartsInScope.
+
+ export_example.remap_chart_configuration produces chart_configuration keyed by
+ chart UUIDs with UUID values in crossFilters.chartsInScope.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ "CHART2": {
+ "id": "CHART2",
+ "meta": {"chartId": 102, "uuid": "uuid2"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ # UUID-keyed format from export_example
+ "uuid1": {
+ "id": "uuid1",
+ "crossFilters": {
+ "chartsInScope": ["uuid2"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ "uuid2": {
+ "id": "uuid2",
+ "crossFilters": {
+ "chartsInScope": ["uuid1"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1, "uuid2": 2}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # UUID keys should be remapped to new integer keys
+ assert "1" in chart_cfg
+ assert "2" in chart_cfg
+ assert "uuid1" not in chart_cfg
+ assert "uuid2" not in chart_cfg
+ # Inner id fields should be new integer IDs
+ assert chart_cfg["1"]["id"] == 1
+ assert chart_cfg["2"]["id"] == 2
+ # chartsInScope UUIDs should be remapped to new integer IDs
+ assert chart_cfg["1"]["crossFilters"]["chartsInScope"] == [2]
+ assert chart_cfg["2"]["crossFilters"]["chartsInScope"] == [1]
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_unknown_preserved():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this newly added function (for example, `-> None`) to comply with the type hint rule. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This newly added test definition has no explicit return type annotation. That directly violates the custom rule about typing new Python definitions.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20400%3A400%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20newly%20added%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20comply%20with%20the%20type%20hint%20rule.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctnes
s%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20400%3A400%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20newly%20added%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20comply%20with%20the%20type%20hint%20rule.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20
fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/dashboards/commands/importers/v1/utils_test.py
**Line:** 400:400
**Comment:**
*Custom Rule: Add an explicit return type annotation to this newly added function (for example, `-> None`) to comply with the type hint rule.
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%2F38171&comment_hash=7e996c979f750bfe511b3fece68d72ae65da58e8b1f123b80c50e0325c5007c6&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=7e996c979f750bfe511b3fece68d72ae65da58e8b1f123b80c50e0325c5007c6&reaction=dislike'>👎</a>
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -123,6 +123,53 @@ def test_update_native_filter_config_scope_excluded():
}
+def test_update_native_filter_charts_in_scope():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this new test function (for example, `-> None`) to satisfy the typing requirement for new Python definitions. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The function is newly added and has no explicit return type annotation. This matches the custom rule requiring new Python definitions to include type hints, so the suggestion identifies a real violation.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20126%3A126%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20satisfy%20the%20typing%20requirement%20for%20new%20Python%20definitions.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%2
0validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20126%3A126%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20to%20satisfy%20the%20typing%20requirement%20for%20new%20Python%20definitions.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20th
e%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/dashboards/commands/importers/v1/utils_test.py
**Line:** 126:126
**Comment:**
*Custom Rule: Add an explicit return type annotation to this new test function (for example, `-> None`) to satisfy the typing requirement for new Python definitions.
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%2F38171&comment_hash=b7330ceaeff1b78d44536720e3358b71757464bfa0830637e8694d686810ee3a&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=b7330ceaeff1b78d44536720e3358b71757464bfa0830637e8694d686810ee3a&reaction=dislike'>👎</a>
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
+ """
+ Test that UUID-keyed chart_configuration entries (from example exports) are
+ properly remapped to new integer IDs during import, including UUID values in
+ chartsInScope.
+
+ export_example.remap_chart_configuration produces chart_configuration keyed by
+ chart UUIDs with UUID values in crossFilters.chartsInScope.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ "CHART2": {
+ "id": "CHART2",
+ "meta": {"chartId": 102, "uuid": "uuid2"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ # UUID-keyed format from export_example
+ "uuid1": {
+ "id": "uuid1",
+ "crossFilters": {
+ "chartsInScope": ["uuid2"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ "uuid2": {
+ "id": "uuid2",
+ "crossFilters": {
+ "chartsInScope": ["uuid1"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1, "uuid2": 2}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # UUID keys should be remapped to new integer keys
+ assert "1" in chart_cfg
+ assert "2" in chart_cfg
+ assert "uuid1" not in chart_cfg
+ assert "uuid2" not in chart_cfg
+ # Inner id fields should be new integer IDs
+ assert chart_cfg["1"]["id"] == 1
+ assert chart_cfg["2"]["id"] == 2
+ # chartsInScope UUIDs should be remapped to new integer IDs
+ assert chart_cfg["1"]["crossFilters"]["chartsInScope"] == [2]
+ assert chart_cfg["2"]["crossFilters"]["chartsInScope"] == [1]
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_unknown_preserved():
+ """
+ Test that UUID-keyed chart_configuration entries with no matching position
+ entry are preserved unchanged rather than silently dropped.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ unknown_uuid = "ffffffff-0000-0000-0000-000000000000"
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ "101": {"id": 101, "crossFilters": {"scope": {"excluded": []}}},
+ unknown_uuid: {"id": unknown_uuid, "crossFilters": {}},
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # Integer-keyed entry should be remapped
+ assert "1" in chart_cfg
+ assert "101" not in chart_cfg
+ # Unknown UUID-keyed entry should be preserved unchanged
+ assert unknown_uuid in chart_cfg
+
+
+def test_update_id_refs_cross_filter_charts_in_scope():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this new test function (for example, `-> None`) so all new Python definitions include type hints. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The function is a newly introduced Python definition and is missing a return type hint. This is a genuine match for the custom typing rule.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20437%3A437%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20so%20all%20new%20Python%20definitions%20include%20type%20hints.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20th
e%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fdashboards%2Fcommands%2Fimporters%2Fv1%2Futils_test.py%0A%2A%2ALine%3A%2A%2A%20437%3A437%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20to%20this%20new%20test%20function%20%28for%20example%2C%20%60-%3E%20None%60%29%20so%20all%20new%20Python%20definitions%20include%20type%20hints.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20
if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/dashboards/commands/importers/v1/utils_test.py
**Line:** 437:437
**Comment:**
*Custom Rule: Add an explicit return type annotation to this new test function (for example, `-> None`) so all new Python definitions include type hints.
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%2F38171&comment_hash=75175b084e27ea3e18c1864e9c0178ad8c8fa6872ea299921c0d7fb0d967e4f4&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38171&comment_hash=75175b084e27ea3e18c1864e9c0178ad8c8fa6872ea299921c0d7fb0d967e4f4&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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4015315295
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-3941808787
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4635274759
**Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save 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
Re: [PR] fix(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4035511279
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2898624200
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
Review Comment:
Thanks for the detailed analysis\! This is a pre-existing issue — the original code (before this PR) also used `int(old_id_str)` and silently skipped non-integer keys on `ValueError`, so the UUID-keyed export scenario was already broken prior to this change. This PR doesn't make that behavior worse. Happy to address UUID-keyed `chart_configuration` in a follow-up, but it's out of scope for this 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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2920496729
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
Review Comment:
Good catch — and this is the more complete fix. We now build a `uuid_to_new_id` map (from position data) alongside `id_map`, and propagate it through `update_cross_filter_scoping`, `_update_cross_filter_scope`, and `_remap_chart_ids`. UUID keys in `chart_configuration` are resolved to new integer IDs, UUID values in `chartsInScope` are remapped too, and any unknown UUID keys are preserved unchanged as a safe fallback. Tests updated to cover the full example-export remapping case.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4586578864
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r3364270447
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -160,7 +161,11 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
Review Comment:
Good catch — removed the now-unreachable `_remap_charts_in_scope` helper in 9acda7248d.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r3127214679
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -123,6 +123,53 @@ def test_update_native_filter_config_scope_excluded():
}
+def test_update_native_filter_charts_in_scope():
Review Comment:
Fixed in bca4ee5 — added `-> None`.
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
Review Comment:
Fixed in bca4ee5 — added `-> None`.
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
+ """
+ Test that UUID-keyed chart_configuration entries (from example exports) are
+ properly remapped to new integer IDs during import, including UUID values in
+ chartsInScope.
+
+ export_example.remap_chart_configuration produces chart_configuration keyed by
+ chart UUIDs with UUID values in crossFilters.chartsInScope.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ "CHART2": {
+ "id": "CHART2",
+ "meta": {"chartId": 102, "uuid": "uuid2"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ # UUID-keyed format from export_example
+ "uuid1": {
+ "id": "uuid1",
+ "crossFilters": {
+ "chartsInScope": ["uuid2"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ "uuid2": {
+ "id": "uuid2",
+ "crossFilters": {
+ "chartsInScope": ["uuid1"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1, "uuid2": 2}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # UUID keys should be remapped to new integer keys
+ assert "1" in chart_cfg
+ assert "2" in chart_cfg
+ assert "uuid1" not in chart_cfg
+ assert "uuid2" not in chart_cfg
+ # Inner id fields should be new integer IDs
+ assert chart_cfg["1"]["id"] == 1
+ assert chart_cfg["2"]["id"] == 2
+ # chartsInScope UUIDs should be remapped to new integer IDs
+ assert chart_cfg["1"]["crossFilters"]["chartsInScope"] == [2]
+ assert chart_cfg["2"]["crossFilters"]["chartsInScope"] == [1]
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_unknown_preserved():
Review Comment:
Fixed in bca4ee5 — added `-> None`.
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -284,3 +331,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped():
+ """
+ Test that UUID-keyed chart_configuration entries (from example exports) are
+ properly remapped to new integer IDs during import, including UUID values in
+ chartsInScope.
+
+ export_example.remap_chart_configuration produces chart_configuration keyed by
+ chart UUIDs with UUID values in crossFilters.chartsInScope.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ "CHART2": {
+ "id": "CHART2",
+ "meta": {"chartId": 102, "uuid": "uuid2"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ # UUID-keyed format from export_example
+ "uuid1": {
+ "id": "uuid1",
+ "crossFilters": {
+ "chartsInScope": ["uuid2"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ "uuid2": {
+ "id": "uuid2",
+ "crossFilters": {
+ "chartsInScope": ["uuid1"], # UUID reference
+ "scope": {"excluded": []},
+ },
+ },
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1, "uuid2": 2}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # UUID keys should be remapped to new integer keys
+ assert "1" in chart_cfg
+ assert "2" in chart_cfg
+ assert "uuid1" not in chart_cfg
+ assert "uuid2" not in chart_cfg
+ # Inner id fields should be new integer IDs
+ assert chart_cfg["1"]["id"] == 1
+ assert chart_cfg["2"]["id"] == 2
+ # chartsInScope UUIDs should be remapped to new integer IDs
+ assert chart_cfg["1"]["crossFilters"]["chartsInScope"] == [2]
+ assert chart_cfg["2"]["crossFilters"]["chartsInScope"] == [1]
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_unknown_preserved():
+ """
+ Test that UUID-keyed chart_configuration entries with no matching position
+ entry are preserved unchanged rather than silently dropped.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
+
+ unknown_uuid = "ffffffff-0000-0000-0000-000000000000"
+ config: dict[str, Any] = {
+ "position": {
+ "CHART1": {
+ "id": "CHART1",
+ "meta": {"chartId": 101, "uuid": "uuid1"},
+ "type": "CHART",
+ },
+ },
+ "metadata": {
+ "chart_configuration": {
+ "101": {"id": 101, "crossFilters": {"scope": {"excluded": []}}},
+ unknown_uuid: {"id": unknown_uuid, "crossFilters": {}},
+ }
+ },
+ }
+
+ chart_ids = {"uuid1": 1}
+ dataset_info: dict[str, dict[str, Any]] = {}
+
+ fixed = update_id_refs(config, chart_ids, dataset_info)
+
+ chart_cfg = fixed["metadata"]["chart_configuration"]
+ # Integer-keyed entry should be remapped
+ assert "1" in chart_cfg
+ assert "101" not in chart_cfg
+ # Unknown UUID-keyed entry should be preserved unchanged
+ assert unknown_uuid in chart_cfg
+
+
+def test_update_id_refs_cross_filter_charts_in_scope():
Review Comment:
Fixed in bca4ee5 — added `-> None`.
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +140,101 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
- fixed = update_cross_filter_scoping(fixed, id_map)
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map, uuid_to_new_id
+ )
+
+ fixed = update_cross_filter_scoping(fixed, id_map, uuid_to_new_id)
return fixed
+def _remap_chart_ids(
+ id_list: list[Any],
+ id_map: dict[int, int],
+ uuid_to_new_id: dict[str, int] | None = None,
+) -> list[int]:
+ """Remap old chart IDs (int or UUID string) to new integer IDs.
+
+ Handles both the standard import format (integer IDs) and the example-export
+ format (UUID strings produced by export_example.remap_chart_configuration).
+ """
+ result = []
+ for item in id_list:
+ if isinstance(item, int):
+ if item in id_map:
+ result.append(id_map[item])
+ elif isinstance(item, str) and uuid_to_new_id:
+ new_id = uuid_to_new_id.get(item)
+ if new_id is not None:
+ result.append(new_id)
+ return result
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any],
+ id_map: dict[int, int],
+ uuid_to_new_id: dict[str, int] | None = None,
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map, uuid_to_new_id)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(
+ charts_in_scope, id_map, uuid_to_new_id
+ )
Review Comment:
Fixed in 5af0eea — added an `isinstance(cross_filter_config, dict)` guard at the top of `_update_cross_filter_scope` so malformed payloads (e.g. `global_chart_configuration: null` or non-dict `crossFilters`) are skipped instead of raising `AttributeError` during import.
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4042161330
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2885418797
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
Review Comment:
The newly added `chartsInScope` remapping logic here duplicates exactly what the `_remap_chart_ids` helper function (introduced in this same PR at line 154) does. Consider using the helper to reduce duplication:
```python
native_filter["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
```
This would make the code more consistent with how the same remapping is done in `_update_cross_filter_scope`.
```suggestion
native_filter["chartsInScope"] = _remap_chart_ids(
charts_in_scope, id_map
)
```
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-3941810470
## **Sequence Diagram**
Shows how the import process now remaps chartsInScope references (native filters, global config, and per-chart cross-filters) using the new chart ID map so imported dashboards reference the newly created charts.
```mermaid
sequenceDiagram
participant Importer
participant Utils
participant IDMap
participant Storage
Importer->>Utils: update_id_refs(config, id_map)
Utils->>IDMap: resolve chart UUIDs -> id_map
Utils->>Utils: Remap native_filter_configuration.chartsInScope using id_map
Utils->>Utils: update_cross_filter_scoping -> remap global_chart_configuration.chartsInScope and chart_configuration[*].crossFilters.chartsInScope
Utils-->>Importer: return fixed config (all chartsInScope updated)
Importer->>Storage: create/import dashboard and charts with updated references
```
---
*Generated by [CodeAnt AI](https://codeant.ai)*
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #38171:
URL: https://github.com/apache/superset/pull/38171
--
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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4300392047
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r2898624098
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
Review Comment:
Good catch — applied\! I've updated the code to use `_remap_chart_ids` for consistency.
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -139,55 +139,70 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
native_filter["scope"]["excluded"] = [
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
+
+ # fix chartsInScope references (from PR #26389)
+ charts_in_scope = native_filter.get("chartsInScope", [])
+ if charts_in_scope:
+ native_filter["chartsInScope"] = [
+ id_map[old_id] for old_id in charts_in_scope if old_id in id_map
+ ]
+
fixed = update_cross_filter_scoping(fixed, id_map)
return fixed
+def _remap_chart_ids(id_list: list[int], id_map: dict[int, int]) -> list[int]:
+ """Remap old chart IDs to new IDs, dropping any that aren't in the map."""
+ return [id_map[old_id] for old_id in id_list if old_id in id_map]
+
+
+def _update_cross_filter_scope(
+ cross_filter_config: dict[str, Any], id_map: dict[int, int]
+) -> None:
+ """Update scope.excluded and chartsInScope in a cross-filter configuration."""
+ scope = cross_filter_config.get("scope", {})
+ if isinstance(scope, dict):
+ if excluded := scope.get("excluded", []):
+ scope["excluded"] = _remap_chart_ids(excluded, id_map)
+
+ if charts_in_scope := cross_filter_config.get("chartsInScope", []):
+ cross_filter_config["chartsInScope"] = _remap_chart_ids(charts_in_scope, id_map)
+
+
def update_cross_filter_scoping(
config: dict[str, Any], id_map: dict[int, int]
) -> dict[str, Any]:
- # fix cross filter references
+ """Fix cross filter references by remapping chart IDs."""
fixed = config.copy()
+ metadata = fixed.get("metadata", {})
- cross_filter_global_config = fixed.get("metadata", {}).get(
- "global_chart_configuration", {}
- )
- scope_excluded = cross_filter_global_config.get("scope", {}).get("excluded", [])
- if scope_excluded:
- cross_filter_global_config["scope"]["excluded"] = [
- id_map[old_id] for old_id in scope_excluded if old_id in id_map
- ]
+ # Update global_chart_configuration
+ global_config = metadata.get("global_chart_configuration", {})
+ _update_cross_filter_scope(global_config, id_map)
- if "chart_configuration" in (metadata := fixed.get("metadata", {})):
- # Build remapped configuration in a single pass for clarity/readability.
- new_chart_configuration: dict[str, Any] = {}
- for old_id_str, chart_config in metadata["chart_configuration"].items():
- try:
- old_id_int = int(old_id_str)
- except (TypeError, ValueError):
- continue
-
- new_id = id_map.get(old_id_int)
- if new_id is None:
- continue
-
- if isinstance(chart_config, dict):
- chart_config["id"] = new_id
-
- # Update cross filter scope excluded ids
- scope = chart_config.get("crossFilters", {}).get("scope", {})
- if isinstance(scope, dict):
- excluded_scope = scope.get("excluded", [])
- if excluded_scope:
- chart_config["crossFilters"]["scope"]["excluded"] = [
- id_map[old_id]
- for old_id in excluded_scope
- if old_id in id_map
- ]
-
- new_chart_configuration[str(new_id)] = chart_config
-
- metadata["chart_configuration"] = new_chart_configuration
+ # Update chart_configuration entries
+ if "chart_configuration" not in metadata:
+ return fixed
+
+ new_chart_configuration: dict[str, Any] = {}
+ for old_id_str, chart_config in metadata["chart_configuration"].items():
+ try:
+ old_id_int = int(old_id_str)
Review Comment:
Thanks for the detailed analysis\! This is a pre-existing issue — the original code (before this PR) also used `int(old_id_str)` and silently skipped non-integer keys on `ValueError`, so the UUID-keyed export scenario was already broken prior to this change. This PR doesn't make that behavior worse. Happy to address UUID-keyed `chart_configuration` in a follow-up, but it's out of scope for this 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(dashboard): replace chartsInScope references at import time [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4015154385
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 90020e89cb76064a3a34590606d843d2f37a190a |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69ab7ea31448400008780bda |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-38171--superset-docs-preview.netlify.app](https://deploy-preview-38171--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-38171--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(dashboard): replace chartsInScope references at import time [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38171:
URL: https://github.com/apache/superset/pull/38171#issuecomment-4626668973
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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(dashboard): replace chartsInScope references at import time [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #38171:
URL: https://github.com/apache/superset/pull/38171#discussion_r3361681588
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -160,7 +161,11 @@ def update_id_refs( # pylint: disable=too-many-locals # noqa: C901
id_map[old_id] for old_id in scope_excluded if old_id in id_map
]
Review Comment:
This replaced the last call to `_remap_charts_in_scope` in `update_id_refs`. The other two callers in `update_cross_filter_scoping` were also removed in this PR, leaving `_remap_charts_in_scope` (defined at line 65) unreachable. Its old in-place-mutator signature `(container, id_map)` diverges from the new `_remap_chart_ids(id_list, id_map, uuid_to_new_id)` — a future reader could reach for it and silently miss UUID-string support. Suggest deleting lines 65–77.
##########
tests/unit_tests/dashboards/commands/importers/v1/utils_test.py:
##########
@@ -666,3 +666,177 @@ def test_update_id_refs_handles_missing_time_grains():
filter_config = fixed["metadata"]["native_filter_configuration"][0]
assert filter_config.get("filterType") == "filter_timegrain"
assert "time_grains" not in filter_config
+
+
+def test_update_id_refs_cross_filter_uuid_keyed_config_remapped() -> None:
+ """
+ Test that UUID-keyed chart_configuration entries (from example exports) are
+ properly remapped to new integer IDs during import, including UUID values in
+ chartsInScope.
+
+ export_example.remap_chart_configuration produces chart_configuration keyed by
+ chart UUIDs with UUID values in crossFilters.chartsInScope.
+ """
+ from superset.commands.dashboard.importers.v1.utils import update_id_refs
Review Comment:
Inline import follows the pre-existing file convention (`# pylint: disable=import-outside-toplevel` on line 17, used throughout the file). Same pattern at lines 739 and 777. Not a regression introduced here — low priority if the file is ever standardized.
--
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