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

   ### SUMMARY
   
   `chartsInScope` / `tabsInScope` on native filters, and the `chartsInScope` 
lists inside `chart_configuration` / `global_chart_configuration`, are 
denormalized caches of `scope` + `position_json`. They are stamped on save and 
never revisited, so seeded, imported and edited dashboards serve scope arrays 
naming charts they don't contain — on a seeded dashboard that was never saved, 
9 of 11 entries pointed at nonexistent charts. The client already ignores them 
and recomputes from the live layout, which is why the JSON Metadata panel and 
`GET /api/v1/dashboard/{id}` returned different documents for the same 
dashboard with no save in between.
   
   This derives them on read from the same rules the client uses 
(`calculateScopes` / `getChartIdsInFilterScope` / 
`getCrossFiltersConfiguration`), in `superset/dashboards/filter_scope.py`, 
wired into the three read paths that hand the caches to a caller: `GET 
/api/v1/dashboard/{id}`, `GET /api/v1/dashboard/{id}/tabs`, and the `PUT 
/api/v1/dashboard/{id}/filters` response. Storage is untouched — deriving is 
read-only.
   
   The frontend change is the matching guard: `PUT /filters` returns the whole 
config, so before this the persisted scope of every *untouched* filter 
overwrote the correct in-session value, and `DashboardContainer`'s equality 
guard saw no change and never recomputed. Dropping the two derived keys from 
that response lets the reducers keep what `calculateScopes` computed.
   
   One known remainder: the panel also lists default `chart_configuration` 
entries for cross-filter-capable charts that have never been scoped. The client 
materialises those from the viz-type registry, which has no backend equivalent, 
so the API cannot reproduce them. After this change both surfaces only ever 
name charts that exist.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — the change is in the API payload, not in any rendered surface.
   
   ### TESTING INSTRUCTIONS
   
   1. Open a seeded dashboard with native filters (e.g. *Video Game Sales*) on 
a fresh load.
   2. Edit properties → Advanced settings → JSON Metadata; copy the contents; 
close without saving.
   3. In the console: `var r = await (await 
fetch('/api/v1/dashboard/{id}')).json(); JSON.parse(r.result.json_metadata)`.
   4. `chartsInScope`, `tabsInScope` and the `chart_configuration` keys now 
match the panel and name only charts present in `position_json`.
   5. Rename one filter via the filter-config modal and repeat — the other 
filters keep their computed scope instead of reverting.
   
   `pytest tests/unit_tests/dashboards/filter_scope_test.py` and 
`tests/integration_tests/dashboards/api_tests.py -k derives_stale_filter_scope`.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: No — reported through Preset support.
   - [ ] Required feature flags: None.
   - [ ] Changes UI: No — backend read path plus one Redux action.
   - [ ] Includes DB Migration: No — no schema or data change; stored 
`json_metadata` is left as-is.
   - [ ] Introduces new feature or API: No.
   - [ ] Removes existing feature or API: No. `GET /api/v1/dashboard/{id}` no 
longer returns `json_metadata` byte-identical to the stored column: the derived 
scope keys are corrected and `chart_configuration` entries for charts absent 
from the layout are dropped, matching what the client already does on load.


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

To unsubscribe, e-mail: [email protected]

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


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

Reply via email to