eschutho opened a new pull request, #42898:
URL: https://github.com/apache/superset/pull/42898
### SUMMARY
Saving any filter through the dashboard filter-configuration modal strips
several keys from the stored `native_filter_configuration` entry of native
filters that have no dataset — most notably Time Range (`filter_time`)
filters. `filter_select` filters are unaffected.
**Problem**
The modal's save path transforms each modified filter's form state into the
object written to `json_metadata`. It decides whether a value is an
in-progress form item (needs full serialization) or an already-saved filter
(pass-through) by checking for a `dataset` key:
```ts
function isFormInput(formInputs): formInputs is NativeFiltersFormItem {
return 'dataset' in formInputs;
}
```
Filter types without a dataset control never populate a `dataset` field on
their form item (their plugin declares `datasourceCount: 0`, so the dataset
control is not rendered). Those form items are therefore misclassified as
already-saved filters and persisted verbatim. As a result the serialized
entry:
- loses `targets`, `defaultDataMask`, and `cascadeParentIds` (built during
the
form → filter transform, which was skipped), and
- gains form-only keys such as `defaultValueQueriesData: null` and a raw
`requiredFirst: {}`.
Because the modal rewrites every modified entry, editing/renaming/reordering
any filter on the dashboard triggers this for the dataset-less filters.
**Fix**
Discriminate on the `targets` array instead of `dataset`. Every saved filter
carries a serialized `targets` array and no form item ever does, so
dataset-less filters now flow through the same serialization path as
dataset-backed ones. The change is limited to the affected entry — insertion
order and untouched entries are preserved.
### TESTING INSTRUCTIONS
Automated: `transformers/filterTransformer.test.ts` covers a dataset-less
(`filter_time`) form item, a dataset-backed (`filter_select`) form item, and
an already-saved filter passed through from the config map. The first case
fails on `master` (missing `targets`) and passes with this change.
```
cd superset-frontend
npm run test --
src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.test.ts
```
Manual:
1. Open a dashboard that has a Time Range native filter.
2. `GET /api/v1/dashboard/{id}` and note the Time Range entry in
`result.json_metadata` has `targets`, `defaultDataMask`, and
`cascadeParentIds`.
3. In the filter bar, edit filters, rename the Time Range filter, and save
without changing anything else.
4. `GET /api/v1/dashboard/{id}` again: only the name changes; the previously
stripped keys are preserved. (Verify against the API response, not the
Edit properties → JSON Metadata panel, which does not render the stored
document.)
### ADDITIONAL INFORMATION
- [x] Bugfix
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-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: [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]