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

   ### SUMMARY
   
   Metric warning text entered through **Explore → dataset overflow menu → Edit 
dataset** was blank when the modal was reopened, even though the warning icon 
still rendered next to the metric name. Editing the same metric from **Datasets 
→ Edit dataset** worked correctly.
   
   **Root cause**
   
   The two entry points hand `DatasourceEditor` metrics in different shapes:
   
   - The Datasets page fetches `/api/v1/dataset/{id}`, whose payload includes 
the raw `extra` JSON string (`metrics.extra` is in the API's `show_columns`).
   - Explore uses the datasource already in its page state, which is serialized 
by `SqlMetric.data` (`superset/connectors/sqla/models.py`). That property 
exposes `warning_markdown` as a **flattened top-level field** and does not 
include `extra` at all.
   
   `DatasourceEditor`'s initial metrics transform derived `warning_markdown` 
solely by parsing `extra`, falling back to `''`:
   
   ```js
   warning_markdown: warningMarkdown || '',
   ```
   
   So for Explore-shaped metrics — where `extra` is absent but 
`warning_markdown` is already populated — the saved text was discarded on mount 
and the Warning field rendered empty. The icon kept showing because it is 
rendered from the metric record elsewhere in Explore rather than from this 
transformed state.
   
   The two sibling fields handled in the same transform, 
`certification_details` and `certified_by`, already fall back to the metric's 
own top-level value. `warning_markdown` was the only one missing that fallback; 
this change makes it consistent:
   
   ```js
   warning_markdown: warningMarkdown || metric.warning_markdown || '',
   ```
   
   `extra` still takes precedence, so the Datasets-page path is unchanged.
   
   ### AFTER SCREENSHOTS
   
   **After** — reopening *Edit dataset* from Explore following a page reload. 
The metric's warning text is retained, and the warning icon still shows next to 
`sum__SP_RUR_TOTL` in the metrics panel. On `master` the same screen renders 
the Warning field empty while the icon remains.
   
   <img width="1647" height="1121" alt="Screenshot 2026-08-05 051603" 
src="https://github.com/user-attachments/assets/d0e8c949-f5cb-4c0f-ab48-0f39f434e26b";
 />
   
   Note that the page must be reloaded to reproduce: immediately after saving, 
the modal refetches `/api/v1/dataset/{id}`, whose payload does include `extra`, 
so the warning renders correctly even without this change. The failure only 
shows once the datasource comes from Explore's own payload again.
   
   ### TESTING INSTRUCTIONS
   
   Automated:
   
   ```bash
   cd superset-frontend
   npm run test -- 
src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorWarningMarkdown.test.tsx
   ```
   
   The added test renders `DatasourceEditor` with a metric shaped like 
Explore's payload (top-level `warning_markdown`, no `extra`) and asserts the 
Warning field is populated. It fails on `master` — the field renders empty — 
and passes with this change.
   
   Manual:
   
   1. Open any chart in Explore.
   2. Dataset overflow menu → **Edit dataset** → **Metrics** tab.
   3. Expand a metric, enter text in **Warning**, and save.
   4. **Reload the Explore page.** This step is required — see the note above; 
reopening the modal without a reload does not reproduce the bug on `master`.
   5. Dataset overflow menu → **Edit dataset** → **Metrics** tab, and expand 
the same metric.
   6. The Warning text is retained. On `master` the field is empty here while 
the warning icon still shows next to the metric.
   7. Confirm the **Datasets → Edit dataset** path still shows the same warning 
text.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #42704
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


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

To unsubscribe, e-mail: [email protected]

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


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

Reply via email to