Skip to content

fix(datasets): keep a metric's warning text when editing from Explore - #43177

Open
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/explore-metric-warning-rehydrate
Open

fix(datasets): keep a metric's warning text when editing from Explore#43177
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/explore-metric-warning-rehydrate

Conversation

@bikash-barnwal

Copy link
Copy Markdown

SUMMARY

The Edit dataset modal reached from Explore (dataset overflow menu → Edit dataset) always showed an empty Warning field for a metric whose warning was set, while the same modal reached from Datasets → Edit dataset showed the value correctly. The value was persisted the whole time — hence the warning icon staying put next to the metric name — it just never made it back into the field.

The two entry points hand DatasourceEditor two different metric shapes:

  • the dataset API returns extra as a JSON string;
  • Explore's bootstrap payload goes through SqlMetric.data, which flattens extra into a top-level warning_markdown and drops the raw extra string.

The editor unconditionally read the warning out of JSON.parse(metric.extra || '{}') and normalized the result with || '', so on the Explore path the already-flattened value was overwritten with an empty string.

This extracts the transform as hydrateMetricExtra and treats the parsed extra as authoritative only when extra is actually present, so an already-flattened warning survives. An empty warning inside a present extra still clears the field, so clearing a warning from the Datasets page keeps working.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: Warning field blank on reopen from Explore (warning icon still shown).
After: the saved warning text is rendered in the field.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- src/components/Datasource

Manually:

  1. Open a chart in Explore, click ... beside the dataset name → Edit dataset.
  2. On the Metrics tab, expand a metric and type something into Warning, then Save.
  3. Reopen Edit dataset from Explore and expand the same metric — the warning text is there.
  4. Repeat from Datasets → Edit dataset to confirm that path is unchanged, including clearing the warning.

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

The Edit dataset modal reached from Explore always showed an empty Warning
field for a metric whose warning was set, while the same modal reached from
Datasets showed it correctly.

The two entry points hand the editor two different metric shapes. The dataset
API returns `extra` as a JSON string, but Explore's bootstrap payload goes
through `SqlMetric.data`, which flattens `extra` into `warning_markdown` and
drops the raw string. The editor unconditionally read the warning out of
`JSON.parse(metric.extra || '{}')` and then normalized it with `|| ''`, so on
the Explore path the flattened value was overwritten with an empty string —
the field rendered blank even though the value was persisted, which is why the
warning icon stayed put next to the metric name.

Extract the transform as `hydrateMetricExtra` and treat the parsed `extra` as
authoritative only when `extra` is actually present, so an already-flattened
warning survives. An empty warning inside a present `extra` still clears the
field.

Fixes apache#42704

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2f1171

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 30e9f6f..30e9f6f
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/hydrateMetricExtra.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added change:frontend Requires changing the frontend explore:metrics Related to metrics of Explore labels Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.70%. Comparing base (c068a8c) to head (30e9f6f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43177   +/-   ##
=======================================
  Coverage   66.70%   66.70%           
=======================================
  Files        2872     2872           
  Lines      163447   163451    +4     
  Branches    37727    37730    +3     
=======================================
+ Hits       109024   109028    +4     
  Misses      52293    52293           
  Partials     2130     2130           
Flag Coverage Δ
javascript 73.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend explore:metrics Related to metrics of Explore size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(datasets): Metric Warning text blank after save in Edit Dataset from Explore

2 participants